I want to write a custom archive rule in mongodb that archives the data with some condition.
Let’s say I have a collection A.
If the collection has more than 1000 docs, archive the oldest doc (I have createdAt) until total document count is 1000. So basically, It should not exceed 1000.
Alternatively, I would also love if I was able to archive oldest documents if the total size of the collection reaches a certain threshold. How would I do it?