How to delete objects from an array after some time ? I dont want to use TTLs as it deletes the whole document. I am just creating a notification system when notifications are seen , it will delete the objects

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