Unreact to comments

This commit is contained in:
aeroreyna
2022-04-04 21:14:12 -07:00
parent 137d91bcc3
commit e7c9d56404
2 changed files with 32 additions and 2 deletions
+22 -2
View File
@@ -90,11 +90,11 @@ postDB = (DB)=>{
});
}
DB.newCommentReaction = (postid, commentDate, userid, reaction) => {
DB.newCommentReaction = (postid, commentDate, profileid, reaction) => {
const id = DB.ObjectID(postid);
let update = {
$set:{
["comments.$.reactions." + userid]: reaction,
["comments.$.reactions." + profileid]: reaction,
"comments.$.lastUpdated": new Date(),
lastUpdated: new Date()
}
@@ -108,6 +108,26 @@ postDB = (DB)=>{
});
}
DB.removeCommentReaction = (postid, commentDate, profileid) => {
const id = DB.ObjectID(postid);
let update = {
$unset:{
["comments.$.reactions." + profileid]: '',
"comments.$.lastUpdated": new Date(),
},
$set: {
lastUpdated: new Date()
}
}
return DB.postCols.updateOne({
_id: id,
"comments.createdAt": commentDate
}, update).catch((err)=>{
console.log(err);
return false;
});
}
DB.getPosts = async (profileId, viewerProfileId) => {
const profile = await DB.getProfile(viewerProfileId);
let query = {};