I have a setup where we are concerned about the size of the Mongo db going out of proportion.
capped collection is not an option for us as we are dynamically updating documents.
I am thinking of implementing it in such a way that if the count of the documents reaches 1000 in that collection then 500 documents would be deleted starting from the oldest.
So far i found the following to be most relevant however there is no way to limit and sort on the basis of time. https://docs.mongodb.com/manual/reference/method/Bulk.find.remove/#example
On researching further, I found:
How to delete N numbers of documents in mongodb
however i think there should be something more simple and efficient.