routes on files

This commit is contained in:
Adolfo Reyna
2021-08-07 20:49:02 -07:00
parent 4069054117
commit 5b9c0362e0
8 changed files with 222 additions and 101 deletions

View File

@@ -15,9 +15,7 @@ postDB = (DB)=>{
const id = DB.ObjectID(postid);
let update = {
$set:{
reactions:{
[userid]: reaction
},
["reactions." + userid]: reaction,
lastUpdated: new Date()
}
}
@@ -80,7 +78,15 @@ postDB = (DB)=>{
}
DB.getPosts = (userObj) => {
return DB.postCols.find().toArray().catch((err)=>{
return DB.postCols.find().sort({_id: -1}).toArray().catch((err)=>{
console.log(err);
return false;
});
}
DB.getPostsOfUser = (userId) => {
let userid = DB.ObjectID(userId);
return DB.postCols.find({userid}).sort({_id: -1}).toArray().catch((err)=>{
console.log(err);
return false;
});