Class: Monga::Protocol::Update

Inherits:
Request
  • Object
show all
Defined in:
lib/monga/protocol/update.rb

Constant Summary collapse

FLAGS =
{ 
  upsert: 0,
  multi_update: 1,
}

Constants inherited from Request

Request::OP_CODES

Instance Attribute Summary

Attributes inherited from Request

#connection, #request_id

Instance Method Summary collapse

Methods inherited from Request

#callback_perform, #command, #header, #initialize, #parse_response, #perform

Constructor Details

This class inherits a constructor from Monga::Request

Instance Method Details

#bodyObject



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/monga/protocol/update.rb', line 10

def body
  @body ||= begin
    query = @options[:query]
    update = @options[:update]

    msg = ::BinUtils.append_int32_le!(nil, 0)
    msg << full_name << Monga::NULL_BYTE
    ::BinUtils.append_int32_le!(msg, flags)
    msg << query.to_bson
    msg << update.to_bson
    msg
  end
end