Sort pass limit in Mongo Meteor

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

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

      

But my above query returns all records that are present in the CompanyData collection.

Does anyone know the reason?

+3


source to share


1 answer


This is because the skip and limit options are included in the third argument to , and not as the second parameter. find()

Re-write your request:



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

      

+8


source







All Articles