background icons
background icons 2

Video Belajar

Tonton dan pelajari berbagai topik menarik melalui video pembelajaran eksklusif dari Channel Engineering Digest.

Engineering Digest

13113

Effortlessly Sort Your MongoDB Documents with These Tips and Tricks

🟡 Get 1 to 1 coaching with me: https://topmate.io/engineeringdigest
🟡 Donate: https://paypal.me/engineeringdigest
🟡 Perks: https://www.youtube.com/@EngineeringDigest/join

🔴 Discord: https://discord.gg/FHB3vUmgKm
🔴 Twitch: https://www.twitch.tv/engineeringdigest
🔴 Personal YouTube Channel: https://www.youtube.com/@thevipulvats
🔴 Instagram: https://www.instagram.com/thevipulvats
🔴 Twitter: https://twitter.com/thevipulvats
🔴 LinkedIn: https://www.linkedin.com/in/thevipulvats/
🔴 Website: https://engineeringdigest.net

🔴 Video summary
To sort documents in MongoDB, use the sort() method on a query object, passing in the field or fields to sort by and the sort order (ascending or descending).

For example:
db.collection.find().sort({field: 1})
will sort documents in ascending order by the "field" key,
while
db.collection.find().sort({field: -1}) will sort in descending order.

🔴 Timestamps
Intro 0:00