I have this method for updating just specific fields in a document
function setPlayerDataField(targetUserId, updateObject){
playerDataCollection.update({"userId": targetUserId //Looks for a doc with the userId of the player},{ $set: updateObject },//Uses the $set Mongo modifier to set value at a pathfalse,//Create the document if it does not exist (upsert)true//This query will only affect a single object (multi));}
One More Turn
I have this method for updating just specific fields in a document
It works fine if I do a command like
It would result in the document like this
The value for credits is now 20 yay! This is desired.
However, if I do this command...
It would result in the document like this
All I wanted to do was set only the settings/music value to 0. This result is NOT desired since we lost the sfx value.
So my question is, how do I update a value in a sub object without replacing the whole sub object itself?