2008-11-22 01:00:51 +00:00
|
|
|
require 'mongo/message/message'
|
|
|
|
require 'mongo/message/opcodes'
|
|
|
|
|
|
|
|
module XGen
|
|
|
|
module Mongo
|
|
|
|
module Driver
|
|
|
|
|
|
|
|
class UpdateMessage < Message
|
|
|
|
|
2008-12-08 16:38:42 +00:00
|
|
|
def initialize(db_name, collection_name, sel, obj, repsert)
|
2008-11-22 01:00:51 +00:00
|
|
|
super(OP_UPDATE)
|
|
|
|
write_int(0)
|
2008-12-08 16:38:42 +00:00
|
|
|
write_string("#{db_name}.#{collection_name}")
|
2008-11-22 01:00:51 +00:00
|
|
|
write_int(repsert ? 1 : 0) # 1 if a repsert operation (upsert)
|
|
|
|
write_doc(sel)
|
|
|
|
write_doc(obj)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|