N
N
Nikita2021-02-06 15:13:57
Mongoose
Nikita, 2021-02-06 15:13:57

Is there a way to get the document that comes after the found one?

For example, you need to find a document that was added to the database immediately after the document with id: j1y2312g31uy23.

Is it possible to implement this? If so, how?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Yarkov, 2021-02-06
@Prynik

db.products.find({_id: {$gt: ObjectId("4fdbaf608b446b0477000142") }}).limit(1)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question