class Mongo::Protocol::Update

@api semipublic
and update if no document matching the update query currently exists.
flag in order to indicate they would like to insert the merged selector
If an upsert (update or insert) is desired, users can set the :upsert
a time users should set the :multi_update flag for the update.
The default is to update a single document. In order to update many at
to update documents matching the provided query.
This is a client request message that is sent to the server in order
MongoDB Wire protocol Update message.

def initialize(database, collection, selector, update, options = {})

Options Hash: (**options)
  • :flags (Array) -- The flags for the update message.

Parameters:
  • options (Hash) -- The additional query options.
  • update (Hash) -- The update to perform.
  • selector (Hash) -- The update selector.
  • collection (String, Symbol) -- The collection to update.
  • database (String, Symbol) -- The database to update.

Other tags:
    Example: Perform an upsert -
    Example: Perform a multi update -
    Example: Update single document -
def initialize(database, collection, selector, update, options = {})
  @database    = database
  @collection  = collection
  @namespace   = "#{database}.#{collection}"
  @selector    = selector
  @update      = update
  @flags       = options[:flags] || []
  @upconverter = Upconverter.new(collection, selector, update, flags)
  super
end

def payload

Other tags:
    Since: - 2.1.0

Returns:
  • (BSON::Document) - The event payload.

Other tags:
    Example: Return the event payload. -
def payload
  BSON::Document.new(
    command_name: 'update',
    database_name: @database,
    command: upconverter.command,
    request_id: request_id
  )
end