class Mongo::Protocol::Delete

MongoDB Wire protocol Delete message.

This is a client request message that is sent to the server in order to delete selected documents in the specified namespace.

The operation, by default, operates on many documents. Setting the :single_remove flag allows for a single matching document to be removed.

@api semipublic

Constants

FLAGS

Available flags for a Delete message.

OP_CODE

The operation code required to specify a Delete message. @return [Fixnum] the operation code.

@since 2.5.0

Attributes

upconverter[R]

Public Class Methods

new(database, collection, selector, options = {}) click to toggle source

Creates a new Delete message

@example Remove all users named Tyler.

Query.new('xgen', 'users', {:name => 'Tyler'})

@param database [String, Symbol] The database to remove from. @param collection [String, Symbol] The collection to remove from. @param selector [Hash] The query used to select doc(s) to remove. @param options [Hash] The additional delete options.

@option options :flags [Array] The flags for the delete message.

Supported flags: +:single_remove+
Calls superclass method
# File lib/mongo/protocol/delete.rb, line 43
def initialize(database, collection, selector, options = {})
  @database = database
  @namespace = "#{database}.#{collection}"
  @selector = selector
  @flags = options[:flags] || []
  @upconverter = Upconverter.new(collection, selector, options)
  super
end

Public Instance Methods

payload() click to toggle source

Return the event payload for monitoring.

@example Return the event payload.

message.payload

@return [ BSON::Document ] The event payload.

@since 2.1.0

# File lib/mongo/protocol/delete.rb, line 60
def payload
  BSON::Document.new(
    command_name: 'delete',
    database_name: @database,
    command: upconverter.command,
    request_id: request_id
  )
end