【发布时间】:2017-02-13 13:24:13
【问题描述】:
当用户对帖子发表评论时,我有一个post 的集合,它将保存在名为comments 的嵌入式文档中。现在的问题是我必须在每个2 hours 发送推送通知,例如此You have 12 new comments on this post 用于此帖子的owner。
现在点击推送通知后,它会将我重定向到 seen 这些 cmets 之后的那个 cmets。现在如果一个新的 cmets 反对帖子,那么 2 小时后我会变成这样 You have 3 new comments on this post
您可以在我的架构中看到我将维护 total_comments 字段。问题是我如何管理此 push notification time based 以及如何识别和维护新 cmets 的跟踪记录。我是否应该在架构中添加一些 key 并编写cron jobs 发送推送通知
任何帮助将不胜感激
这是我的记录
{
"_id" : ObjectId("57b3aa2db630347c1f9308b4"),
"updated" : ISODate("2016-08-30T05:05:18.301Z"),
"created" : ISODate("2016-08-17T00:05:01.354Z"),
"createdTimeStamp" : 1471392301,
"likes" : [],
"comments" : [
{
"created" : 1471935213,
"user" : ObjectId("57b33c810a56a0a81a9b50b7"),
"text" : "next party",
"_id" : ObjectId("57bbf2edee7a923c156c2f08")
},
{
"created" : 1471935612,
"user" : ObjectId("57b33c810a56a0a81a9b50b7"),
"text" : "its new party ",
"_id" : ObjectId("57bbf47cddd701302ba14fca")
},
{
"created" : 1471935717,
"user" : ObjectId("57b33c810a56a0a81a9b50b7"),
"text" : "its new again",
"_id" : ObjectId("57bbf4e5f934024c275f4f08")
},
],
"total_comments" : 3,
"consumer_id" : ObjectId("57b33c810a56a0a81a9b50b7") // Original User that receive notification
}
【问题讨论】:
标签: javascript node.js mongodb push-notification scheduled-tasks