简体   繁体   中英

sort array before using mergeObjects MongoDB

I am doing a query in mongo db where I group some documents and I need to merge objects, but the objects has a key of date and I would like to sort the documents before merge objects to have the last values of the objects by date.

Is it possible??

I already could, I had to use two groups in the aggregation, the first one sorted the array of documents that I wanted to merge and then the second group merged the objects.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM