Is this the right way to get documents in descending order meaning last inserted first and so on with the first inserted in the end?

I am currently using
db.<collection_name>.find({}).sort({"_id":-1})

Is this the right way to go ?

Hi @Stuart_S,

Yes, you can do it like that. _id filed is of the type ObjectId, which includes a timestamp.

2 Likes

Thanks Nenad,!!!

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.