How get the last documenti inserted Mongodb

PLCITS
PLCITS used Ask the Experts™
on
How get the last document inserted in mongoDB

Im using nodejs, express mongoose
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Data Engineer
Commented:
Did you try?

db.your_collection_name.find({}).sort({_id:-1}).limit(1)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial