em-mongo 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/em-mongo.rb +1 -1
- data/lib/em-mongo/connection.rb +2 -2
- data/spec/collection_spec.rb +11 -0
- metadata +2 -2
data/lib/em-mongo.rb
CHANGED
data/lib/em-mongo/connection.rb
CHANGED
@@ -81,8 +81,8 @@ module EM::Mongo
|
|
81
81
|
flags += 2 if options[:multi]
|
82
82
|
message.put_int(flags)
|
83
83
|
|
84
|
-
message.put_array(BSON::BSON_CODER.serialize(selector,
|
85
|
-
message.put_array(BSON::BSON_CODER.serialize(document,
|
84
|
+
message.put_array(BSON::BSON_CODER.serialize(selector, true, true).to_a)
|
85
|
+
message.put_array(BSON::BSON_CODER.serialize(document, false, true).to_a)
|
86
86
|
|
87
87
|
req_id = new_request_id
|
88
88
|
message.prepend!(message_headers(OP_UPDATE, req_id, message))
|
data/spec/collection_spec.rb
CHANGED
@@ -87,6 +87,17 @@ describe EMMongo::Collection do
|
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
|
+
it 'should update an object with $inc' do
|
91
|
+
EM::Spec::Mongo.collection do |collection|
|
92
|
+
obj = collection.insert('hello' => 'world')
|
93
|
+
collection.update({'hello' => 'world'}, {'$inc' => {'count' => 1}})
|
94
|
+
collection.find({'_id' => obj['_id']},{}) do |res|
|
95
|
+
res.first['hello'].should == 'world'
|
96
|
+
res.first['count'].should == 1
|
97
|
+
EM::Spec::Mongo.close
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
90
101
|
|
91
102
|
it 'should remove an object' do
|
92
103
|
EM::Spec::Mongo.collection do |collection|
|