admin管理员组

文章数量:1336131

I am using Meteor API for Mongo Collection to sort, skip and limit the records and return it to the client.

return CompanyData.find({},{sort:{overallrating:-1}},{skip:0,limit:30}).fetch();

But my above query is returning all the records that are present in the CompanyData Collection.

Does anybody know the reason?

I am using Meteor API for Mongo Collection to sort, skip and limit the records and return it to the client.

return CompanyData.find({},{sort:{overallrating:-1}},{skip:0,limit:30}).fetch();

But my above query is returning all the records that are present in the CompanyData Collection.

Does anybody know the reason?

Share Improve this question asked Jun 5, 2015 at 13:35 user4523328user4523328
Add a ment  | 

1 Answer 1

Reset to default 11

It's because the skip and limit options are included as a third argument in the find() method rather than the second parameter.

Re-write your query to this:

return CompanyData.find({}, {sort: {overallrating: -1}, skip: 0, limit: 30 }).fetch();

本文标签: javascriptsort skip limit in Mongo MeteorStack Overflow