Class Mongo::BulkWrite
In: lib/mongo/bulk_write.rb
lib/mongo/bulk_write/result_combiner.rb
lib/mongo/bulk_write/combineable.rb
lib/mongo/bulk_write/validatable.rb
lib/mongo/bulk_write/ordered_combiner.rb
lib/mongo/bulk_write/result.rb
lib/mongo/bulk_write/transformable.rb
lib/mongo/bulk_write/unordered_combiner.rb
Parent: Object

Methods

execute   new   ordered?   write_concern  

Included Modules

Retryable

Classes and Modules

Module Mongo::BulkWrite::Combineable
Module Mongo::BulkWrite::Transformable
Module Mongo::BulkWrite::Validatable
Class Mongo::BulkWrite::OrderedCombiner
Class Mongo::BulkWrite::Result
Class Mongo::BulkWrite::ResultCombiner
Class Mongo::BulkWrite::UnorderedCombiner

Constants

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

Attributes

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.

Public Class methods

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

Public Instance methods

Execute the bulk write operation.

@example Execute the bulk write.

  bulk_write.execute

@return [ Mongo::BulkWrite::Result ] The result.

@since 2.1.0

Is the bulk write ordered?

@api private

@example Is the bulk write ordered?

  bulk_write.ordered?

@return [ true, false ] If the bulk write is ordered.

@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

[Validate]