Mongo::Bulk
Inherits Reference / Object
A bulk operations builder.
# A Bulk instance can be obtained by calling `.bulk()` on a collection.
bulk = collection.bulk(ordered: true)
# Then, operations can be added…
500.times { |idx|
bulk.insert_one({number: idx})
bulk.delete_many({number: {"$lt": 450}})
}
# …and they will be performed once the bulk gets executed.
bulk_result = bulk.execute(write_concern: Mongo::WriteConcern.new(w: 1))
pp bulk_result
Instance methods
Execute the bulk operations stored in this Bulk instance.