The key is to use $set
in the update, for example. instead (sorry, using the JavaScript syntax here, not sure about the exact syntax of the PHP driver):
db.my_collection.update({hello: "world"}, {foo: "bar"})
you do
db.my_collection.update({hello: "world"}, {$set: {foo: "bar"}})
If you use $set
, only the properties you specify will be updated, the entire document will not be replaced.
You can read more about this in the documentation: http://www.mongodb.org/display/DOCS/Updating#Updating-ModifierOperations
Edit: looking at your code, this is exactly what you do in the addRow
method. Just do the same in update
.
source share