I\'m trying to use MongoDB\'s Java driver to make two updates ($set and $push) to a record in the same operation. I\'m using code similar to the following:
My mongodb version is 3.4.20 and while using
db.collection.update({_id: pageId}, [{$push: {values: dboVital}}, {$set: {endTime: time}}]);
I received error
[thread1] Error: field names cannot start with $ [$push] :
To solve that error we can use:
db.collection.update({_id: pageId}, {$push: {values: dboVital}, $set: {endTime: time}});