type const addToNotifications = await db.collection("notifications").findOneAndUpdate(
{ author: body.author },
{
$addToSet: {
notifications: {
comment: body.comment,
notifier: body.commenter,
postId: body.postId,
notificationType: "comment",
isSeen: false,
createdAt: new Date(),
},
},
},
{ returnDocument: "after" }
);
const removeFromNotifications = await db.collection("notifications").findOneAndUpdate(
{ author: body.author },
{
$pull: {
notifications: {
isSeen: true,
createdAt: { $lt: new Date(Date.now() - 1 * 60 * 1000) }, // Older than 1 day
},
},
},
{ returnDocument: "after" }
); or paste code here
``` here is my code
Skip to main content
New & Unread Topics
Topic | Replies | Views | Activity |
---|---|---|---|
Installing kafka with k raft | 0 | 361 | Jun 2024 |
System-Initiated Query Exceeding Time Limit on Secondary Server | 0 | 193 | Jul 2024 |
Question regarding single index and compound indexes | 2 | 237 | Aug 2024 |
Is there any pitfall to use UTF-8 character as field name? | 0 | 15 | Nov 2024 |
Cannot create index parallel arrays | 0 | 71 | Jan 6 |