Add createdAt
field, index it, then query
db.getCollection("COLLECTION_NAME").find({"createdAt":{$gt:new Date(Date.now() - 24*60*60 * 1000)}})
This will return all records older then 86400 seconds.
More Related Contents:
- Does MongoDB’s $in clause guarantee order
- Authentication failure while trying to save to mongodb
- Possibility of duplicate Mongo ObjectId’s being generated in two different collections?
- How to change the type of a field?
- MongoDB logging all queries
- Converting string to date in mongodb
- Querying internal array size in MongoDB
- MongoDB wildcard in the key of a query
- How to create a DB for MongoDB container on start up?
- How to access a preexisting collection with Mongoose?
- How to delete N numbers of documents in mongodb
- How do I query for distinct values in Mongoose?
- MongoDB field order and document position change after update
- MongoDB Full and Partial Text Search
- Mongodb Join on _id field from String to ObjectId
- Difference between count() and find().count() in MongoDB
- How to insert an element to MongoDB internal list?
- Hierarchical queries with Mongo using $graphLookup
- Remove embedded document in a nested array of documents
- Find all documents within last n days
- Unable to create/open lock file: /data/mongod.lock errno:13 Permission denied
- Search on multiple collections in MongoDB
- Image returned from REST API always displays broken
- MongoDB: Server has startup warnings ”Access control is not enabled for the database”
- Mongo group and push: pushing all fields
- How to stop insertion of Duplicate documents in a mongodb collection
- Filtering embedded documents in MongoDB
- Remove multiple documents from mongo in a single query
- Mongodb concat int and string
- Aggregation with update in mongoDB