mongoDB - find first x documents, where aggregated sum of their fields exceeds certain value

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP

mongoDB - find first x documents, where aggregated sum of their fields exceeds certain value



I have a mongoDB collection of documents like this:



"_id": 1,
"size": 10,
"name": "ABCD"



I would like to:



I have briefly looked into $redact stage of aggregation framework, but I can't figure out whether I can store the cumulative sum outside the document. What would be the best approach to solve this problem?





sort by name and get documents whose size value >=100. What else do you want to do (regarding whose sum are you talking about).
– Helping hand
1 hour ago






db.collection.find( "size": "$gte": 100 ).sort( name: 1 )
– Anthony Winzlet
1 hour ago


db.collection.find( "size": "$gte": 100 ).sort( name: 1 )





@Helpinghand it's the cumulative size of documents that I'm talking about. Let me clarify the question
– Tony Sepia
just now









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

Executable numpy error

Trying to Print Gridster Items to PDF without overlapping contents

Mass disable jenkins jobs