Reputation: 28174
Photo.new
).Questions
Upvotes: 2
Views: 1205
Reputation: 1170
Yes, there is a limit. Everything you're going to batch insert using the method coreyward just described should be within 16M (MongoDB's document size limit). Look here:
https://github.com/mongodb/mongo-ruby-driver/commit/4712a684689c11a31221c87354e5ae0864960226
So you should estimate your array's byte size and split it into several parts if it exceeds 16M.
Upvotes: 1
Reputation: 80120
I'm not familiar with the Ruby Mongoid driver, but it seems like you're looking for something like:
photos.map &:save
If you are trying to do this in a less iterative fashion (i.e. in a single call) it appears that the Ruby Mongoid driver supports an insert
method to save an array of hashes:
Photo.collection.insert(photos)
Source: Batch insert/update using Mongoid?
Upvotes: 3