【发布时间】:2013-10-03 13:50:27
【问题描述】:
我想在流星中运行查询并将返回的字段数限制为 5。这是我的代码:
var courses = Courses.find(
{ day_of_week : {$in: day_selector},
price : {$gt : price_min, $lt : price_max},
starts : {$gt : schedule_min},
ends : {$lt : schedule_max}},
{limit : 10});
console.log(courses);
return courses;
但是,当我这样做时,我会在控制台日志中获得所有适合选择器的课程,而不仅仅是其中的 10 个。在模板中一切正常,只显示了 10 门课程。
我看了这个问题: Limit number of results in Meteor on the server side?
但这并没有帮助,因为我没有为我的课程使用特定的 _id 字段,我使用的是特定的 _id 字段,但用于其他集合。
【问题讨论】: