I have found some information to accomplish this in mongoDB, but I need it with mongoid. So I can do something like:
User.last(7000).each do ...
.
I'm using:
MongoDB shell version: 2.4.3
Mongoid 2.6.0
Thanks!
To get last inserted document, use sort() along with limit(1).
Now I found a solution from mongoid origin:
User.all.desc('_id').limit(7000)
It sorts the users in descending order according to the id.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With