I m trying to do an upsert with ruby driver to mongodb. If the row exist I wish to push new data to and array, else create new document with one item in the array.
当我执政时,我看着:
db.events.update( { "_id" : ObjectId("4f0ef9171d41c85a1b000001")},
{ $push : { "events" : { "field_a" : 1 , "field_b" : "2"}}}, true)
并且是行之有效的。
When I run it on ruby it looks like that:
@col_events.update( { "_id" => BSON::ObjectId.from_string("4f0ef9171d41c85a1b000001")},
{ :$push => { "events" => { "field_a" => 1 , "field_b" => "2"}}}, :$upsert=>true)
但它没有工作。 我不会错过,但我看不到新行。
感谢帮助了解我做错做的事情。