rename to profile, users are people

This commit is contained in:
Adolfo Reyna
2021-08-18 07:57:19 -07:00
parent 416c14d03b
commit 95a7bcb3ff
6 changed files with 46 additions and 33 deletions

View File

@@ -3,19 +3,19 @@ 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.newReaction = (postid, userid, reaction) => {
DB.newReaction = (postid, profileid, reaction) => {
const id = DB.ObjectID(postid);
let update = {
$set:{
["reactions." + userid]: reaction,
["reactions." + profileid]: reaction,
lastUpdated: new Date()
}
}
@@ -78,12 +78,16 @@ postDB = (DB)=>{
}
DB.getPosts = (profileId) => {
let query = profileId ? {
$or: [
{_id: profileId},
{toUser: profileId}
]
} : {};
let query = {};
if(profileId) {
const id = DB.ObjectID(profileId);
query = {
$or: [
{profileid: id},
{toProfile: id}
]
};
}
return DB.postCols.find(query).sort({_id: -1}).toArray().catch((err)=>{
console.log(err);
return false;