Class Moped::Protocol::Update
In: lib/moped/protocol/update.rb
Parent: Object

The Protocol class for updating documents in a collection.

@example Rename a user

  Update.new "moped", "users", { _id: "123" }, { name: "Bob" }

@example Rename all users named John

  Update.new "moped", "users", { name: "John" }, { name: "Bob" },
    flags: [:multi]

@example Upsert

  Update.new "moped", "users", { name: "John" }, { name: "John" },
    flags: [:upsert]

@example Setting the request id

  Update.new "moped", "users", {}, { name: "Bob" },
    request_id: 123

Methods

log_inspect   new   op_code  

Included Modules

Message

Attributes

collection  [R]  @return [String, Symbol] the collection this insert targets
database  [R]  @return [String, Symbol] the database this insert targets

Public Class methods

Create a new update command. The database and collection arguments are joined together to set the full_collection_name.

@example

  Update.new "moped", "users", { name: "John" }, { name: "Bob" },
    flags: [:upsert],
    request_id: 123

@param [String, Symbol] database the database to insert into @param [String, Symbol] collection the collection to insert into @param [Hash] selector the selector @param [Hash] update the update to perform @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: +:upsert+, +:multi+.

Public Instance methods

@return [Number] OP_UPDATE operation code (2001)

[Validate]