| SINGLE_STATEMENT_OPS | = | [ :delete_one, :update_one, :insert_one ].freeze | ||
| DELETE_ONE_TRANSFORM | = | ->(doc){ { Operation::Q => doc[:filter], Operation::LIMIT => 1 }.tap do |d| d[Operation::COLLATION] = doc[:collation] if doc[:collation] |
Proc to transform delete one ops.
@since 2.1.0 |
| collection | [R] | @return [ Mongo::Collection ] collection The collection. |
| options | [R] | @return [ Hash, BSON::Document ] options The options. |
| requests | [R] | @return [ Array<Hash, BSON::Document> ] requests The requests. |
Create the new bulk write operation.
@api private
@example Create an ordered bulk write.
Mongo::BulkWrite.new(collection, [{ insert_one: { _id: 1 }}])
@example Create an unordered bulk write.
Mongo::BulkWrite.new(collection, [{ insert_one: { _id: 1 }}], ordered: false)
@example Create an ordered mixed bulk write.
Mongo::BulkWrite.new(
collection,
[
{ insert_one: { _id: 1 }},
{ update_one: { filter: { _id: 0 }, update: { '$set' => { name: 'test' }}}},
{ delete_one: { filter: { _id: 2 }}}
]
)
@param [ Mongo::Collection ] collection The collection. @param [ Array<Hash, BSON::Document> ] requests The requests. @param [ Hash, BSON::Document ] options The options.
@since 2.1.0
Execute the bulk write operation.
@example Execute the bulk write.
bulk_write.execute
@return [ Mongo::BulkWrite::Result ] The result.
@since 2.1.0
Get the write concern for the bulk write.
@api private
@example Get the write concern.
bulk_write.write_concern
@return [ WriteConcern ] The write concern.
@since 2.1.0