Is there any way in the mongo shell I can return all documents in a collection, but order them by a specific field and remove any documents with fields the same as other documents?
Thanks.
For sort I would use sort. To remove document with same value: distict.
Something like:
db.collection.find().sort({field : 1}).distinct('field')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With