Start a new topic

Need some help with grouping

In my collection, I have a field called 'vegan' that stores an integer. Each document has a different value for vegan ranging from null->100 . I want to get the top 20 documents with the highest value for 'vegan'.

Are there any examples of this in the BL?
1 Comment

You can simply do a collectionAccess query with a sort and limit.

collectionAccess.myCollection.find({},{“sort”: [[‘vegan’,’desc’]], "limit":20}, callback);
Login or Signup to post a comment