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 user4523328user45233281 Answer
Reset to default 11It'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();