-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: 1.6.1
-
Component/s: Write Ops
-
Labels:None
-
Environment:any
-
ALL
We would like to reduce the number of updates by using the $in operator going from
buckets = [ '2010', '2010-08', '2010-08-01' ]
buckets.each do |bucket|
@totals.update(
, { '$inc' => { 'downloads' => 1 }}, :upsert => true)
end
to
buckets = [ '2010', '2010-08', '2010-08-01' ]
@totals.update({ 'bucket' =>
}, { '$inc' => { 'downloads' => 1 }}, :upsert => true)
Unfortunately we get very strange and inconsistent results.
db.test.find()
db.test.update(
, { "$inc":
{ "d": 1 } }, true)
db.test.find()
db.test.update(
{"b": 3}, { "$inc":
{ "d": 1 } }, true)
db.test.find()
db.test.update({"b":
{ "$in": [ 2, 3, 4 ] }}, { "$inc":
{ "d": 1 } }, true)
db.test.find()
We would expect also
{ "_id" : ObjectId("4c6d1e485153667a3fd349ba"), "b" : 4, "d" : 1 }to be there. Then we found there is 'multi' option to turn on in (from http://www.mongodb.org/display/DOCS/Updating )
"multi - if all documents matching criteria should be updated"
But that still does not create a documents as expected.
db.test.update({"b":
{ "$in": [ 2, 3, 4 ] }}, { "$inc":
{ "d": 1 } }, true, true)
db.test.find()
Now even more weird. Trying again it does create a document - but not the one expected:
db.test.update({"b":
{ "$in": [ 55, 66 ] }}, { "$inc":
{ "d": 1 } }, true, true)
db.test.find()
What are we missing here?