To expire documents after a certain number of seconds, you can create a TTL index, which is a special property of the index, which relies on the background thread in mongod, which reads the values of the target date and performs delete operations for those who have expired.
createdAt, , , "new Date()"
TTL , verifyIndex() expireAfterSeconds.
db.log.ensureIndex({ "createdAt": 1}, {expireAfterSeconds: 3600})
TTL, MongoDB , createdAt , createdAt + expireAfterSeconds (3600 = 60 * 60 ).
, , 60
, : http://mongodbspain.com/en/2014/02/08/expire-data-from-collections-using-ttl/
.