我已经制作了通知集合,并按照以下架构在其中放置了通知:
Give it a try,All the best (yes)
我试图通过分页和排序来显示通知,但我得到了一个特定的顺序。 比如前 N 个通知将指向 1 小时前到 2 天前,然后另一个分页将再次显示 5 小时前到 26 天前,依此类推。
我使用这个查询来查找:
{
userid: mongoose.Schema.Types.ObjectId // the user who generated this notification
customReceivers: [String],time: Number,// new Date().getTime();
... other fields
}
notificationmodel.find({userid: {$in: followingList}}.sort({time: -1}).skip(pageNo * entriesPerPage).limit(entriesPerPage).then(...
我试过用 followingList = [mongoose.ObjectId("60bb75c3eb840300226bd3a8"),mongoose.ObjectId("60bb77eeeb840300226bd3ac"),...]
没用
默认情况下,条目按时间升序保存,我只需要取最后 N 个条目并反转数组。但我得到的顺序是不同的。感谢帮助