In mongodb, documents have a property like this: dateOfPublication: 2021-04-09T21:25:05.612+00:00
.
How can I get, say, the first 3 posts by time?
In mongodb, documents have a property like this: dateOfPublication: 2021-04-09T21:25:05.612+00:00
.
How can I get, say, the first 3 posts by time?
You can achieve this with aggregation. You need two staged:
Example:
db.collection.aggregate([
{$sort: {'dateOfPublication': 1}},
{$limit: 3}
])