rename to profile, users are people
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user