Closed IanButterworth closed 8 years ago
mongo.db requires that you use special "update operators" in order to update specific fields, leaving the others as-is. This seems to be supported in the Julia implementation as suggested in the unit tests:
update(
collection,
("_id" => oid),
set("hello" => "after")
)
Note the set(...)
operation. Without any update operators, mongo.db will replace the entire "document" (using mongo.db terminology), which means effectively removing any fields that aren't provided. For more info on this, see https://docs.mongodb.org/manual/reference/method/db.collection.update/#example-update-specific-fields
BTW this is another place where a small update to the docs would be greatly appreciated -- again, if it's not obvious then it's worth spelling out!
Great. That worked as promised. Thanks. I agree that it's not obvious. 'Set' should be listed as an alternative to 'inc' in the update example
My understanding is that the update function should just affect the fields stated in the update query, but it seems to delete every other field in the record, leaving just the updated field.
Result: ("a" => 323)
not ("a" => 323,"b"=>2,"c"=>3)