class Mongo::Bulk
- Mongo::Bulk
- Reference
- Object
Overview
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
Defined in:
cryomongo/bulk.crInstance Method Summary
-
#collection : Mongo::Collection
The target collection.
-
#delete_many(filter, **options)
Delete one or more documents.
-
#delete_one(filter, **options)
Delete a single document.
-
#execute(write_concern : WriteConcern? = nil, bypass_document_validation : Bool? = nil)
Execute the bulk operations stored in this
Bulk
instance. -
#insert_one(document)
Insert a single document.
-
#ordered? : Bool
Whether the bulk is ordered.
-
#replace_one(filter, replacement, **options)
Replace one document.
-
#update_many(filter, update, **options)
Update many documents.
-
#update_one(filter, update, **options)
Update one document.