Reputation: 1772
A while back when I was researching MongoDB I came across an article where they explained how to be able to insert records but only keep 10 (for example), so once it hit 10 records then it would delete the oldest record and insert the newest. This was all done in a single query (at least I think it was).
Can someone help me out with an example?
Upvotes: 2
Views: 270
Reputation: 11520
It sounds like you want a capped collection.
db.createCollection("just_ten", {capped:true, max:10});
Upvotes: 2