The Protocol class for deleting documents from a collection.
@example Delete all people named John
delete = Delete.new "moped", "people", { name: "John" }
@example Delete the first person named John
delete = Delete.new "moped", "people", { name: "John" }, flags: [:remove_first]
@example Setting the request id
delete = Delete.new "moped", "people", { name: "John" }, request_id: 123
@return [String, Symbol] the collection to delete from
@return [String, Symbol] the database to delete from
Create a new delete command. The database
and
collection
arguments are joined together to set the
full_collection_name
.
@example
Delete.new "moped", "users", { condition: true }, flags: [:remove_first], request_id: 123
@param [String, Symbol] database the database to delete from @param [String, Symbol] collection the collection to delete from @param [Hash] selector the selector for which documents to delete @param [Hash] options additional options @option options [Number] :request_id the command's request id @option options [Array] :flags the flags for insertion. Supported
flags: +:remove_first+
# File lib/moped/protocol/delete.rb, line 71 def initialize(database, collection, selector, options = {}) @database = database @collection = collection @full_collection_name = "#{database}.#{collection}" @selector = selector @request_id = options[:request_id] @flags = options[:flags] end
# File lib/moped/protocol/delete.rb, line 87 def log_inspect type = "DELETE" "%-12s database=%s collection=%s selector=%s flags=%s" % [type, database, collection, selector.inspect, flags.inspect] end
@return [Number] OP_DELETE operation code (2006)
# File lib/moped/protocol/delete.rb, line 83 def op_code 2006 end