I wish to limit the number of records in a table of my database to a 1000. (keeping the newest 1000). I'm sorry I don't have any code to show, I really had no clue how to do it at all.
Thanks for pointing me in the right direction with skip. Although there are 2 bugs in the code you provided (at least for mysql); I will point them out for others stumbling across this question.
You can't use skip without a take
You cant delete with a skip/take (some mysql limitation)
Unfortunately these 2 limitations made me use 2 queries and a loop! I'm sure there is a better way of doing this.