我正在尝试获取集合中的上一个和下一个项目.以下是我尝试过的,但它不起作用.我得到了结果,但他们没有以正确的顺序返回.有什么建议?
以前:
Meteor.videos.find({$lt: currentID}, {sort: {date: -1}, limit:1});
Run Code Online (Sandbox Code Playgroud)
下一个:
Meteor.videos.find({$gt: currentID}, {sort: {date: -1}, limit:1});
Run Code Online (Sandbox Code Playgroud)
尝试查询日期,而不是文档ID.
var current = Meteor.videos.findOne(currentID);
Run Code Online (Sandbox Code Playgroud)
以前:
Meteor.videos.find({date: {$lt: current.date}}, {sort: {date: -1}, limit:1});
Run Code Online (Sandbox Code Playgroud)
下一个:
Meteor.videos.find({date: {$gt: current.date}}, {sort: {date: 1}, limit:1});
Run Code Online (Sandbox Code Playgroud)
您还需要按升序对下一个光标进行排序.
| 归档时间: |
|
| 查看次数: |
1497 次 |
| 最近记录: |