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
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+.
# File lib/moped/protocol/update.rb, line 89 def initialize(database, collection, selector, update, options = {}) @database = database @collection = collection @full_collection_name = "#{database}.#{collection}" @selector = selector @update = update @request_id = options[:request_id] @flags = options[:flags] end
Generated with the Darkfish Rdoc Generator 2.