const DBName = "EMI_SOCIAL"; const Post = require("./../def/post.js") postDB = (DB)=>{ DB.postCols = DB.db.db(DBName).collection("posts"); DB.newPost = (postObj) => { console.log(postObj) return DB.postCols.insertOne(postObj.toObj()).catch((err)=>{ console.log(err); return false; }); } DB.newComment = (postid, comment) => { return DB.postCols.updateOne(postid, { $push: { comments: comment }, $set: { lastUpdated: new Date() } }).catch((err)=>{ console.log(err); return false; }); } DB.getPosts = (userObj) => { return DB.postCols.find().toArray().catch((err)=>{ console.log(err); return false; }); } } module.exports = postDB;