S
S
Sergo Sergo2015-04-16 20:07:23
MongoDB
Sergo Sergo, 2015-04-16 20:07:23

How to get the last added element?

I need to get the last element that was added to the database.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya Shatokhin, 2015-04-16
@iShatokhin

db.collection.findOne({ $query: {}, $orderby: { _id : -1 } })

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question