class Mongo::Operation::Write::Bulk::Update
A MongoDB bulk update operation.
@note If the server version is >= 2.5.5, a write command operation
will be created and sent instead.
@example Create the update operation.
Write::BulkUpdate.new({ :updates => [ { :q => { :foo => 1 }, :u => { :$set => { :bar => 1 }}, :multi => true, :upsert => false } ], :db_name => 'test', :coll_name => 'test_coll', :write_concern => write_concern, :ordered => false })
Initialization:
param [ Hash ] spec The specifications for the update. option spec :updates [ Array ] The update documents. option spec :db_name [ String ] The name of the database on which the query should be run. option spec :coll_name [ String ] The name of the collection on which the query should be run. option spec :write_concern [ Mongo::WriteConcern ] The write concern. option spec :ordered [ true, false ] Whether the operations should be executed in order. option spec :options [ Hash ] Options for the command, if it ends up being a write command.
@since 2.0.0
Private Instance Methods
execute_write_command(context)
click to toggle source
# File lib/mongo/operation/write/bulk/update.rb, line 64 def execute_write_command(context) Result.new(Command::Update.new(spec).execute(context)) end
messages()
click to toggle source
# File lib/mongo/operation/write/bulk/update.rb, line 69 def messages updates.collect do |u| opts = { :flags => [] } opts[:flags] << :multi_update if !!u[Operation::MULTI] opts[:flags] << :upsert if !!u[Operation::UPSERT] Protocol::Update.new(db_name, coll_name, u[Operation::Q], u[Operation::U], opts) end end