D
D
driverx182020-01-06 13:07:50
MongoDB
driverx18, 2020-01-06 13:07:50

What is the most efficient way to get all documents that are older than 1 day?

I know that it is possible to get its timestamp through the ObjectId of a document. But what if I need to get all the documents in the collection that are older than one day? Walking through each document and checking its ObjectId is not the best option.
Do I understand correctly that when adding to MongoDB, you need to make a field a la created_at?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimonchik, 2020-01-06
@dimonchik2013

doesn't work like that?
https://gist.github.com/guilleferrer/1669783
the field is not needed, it is only needed for specifics and normalization - for example, different zones with server time, normalized to the datetime event, etc.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question