Reputation: 5226
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!
Upvotes: 18
Views: 8558
Reputation: 1
Aggregations can directly be chained to a Model in rails irrespective of the ORM used. We don't need to use all
. You could just do the following
User.limit(3000).desc('_id')
This will only return the Mongoid criteria. To see the data you can chain .all
to the criteria. You can directly do operations on the criteria also, without having to chain .all
or to_a
.
Upvotes: 0