module Mongoid::Relations::Embedded::Batchable

Public Instance Methods

batch_insert(docs) click to toggle source
# File lib/patches/push_each.rb, line 10
def batch_insert(docs)
  execute_batch_insert(docs, "$push", true)
end
execute_batch_insert(docs, operation, use_each = false) click to toggle source
# File lib/patches/push_each.rb, line 14
def execute_batch_insert(docs, operation, use_each = false)
  self.inserts_valid = true
  inserts = pre_process_batch_insert(docs)
  if insertable?
    collection.find(selector).update(
        positionally(selector, operation => { path => use_each ? { '$each' => inserts } : inserts })
    )
    post_process_batch_insert(docs)
  end
  inserts
end