So I\'m using the MongoDB driver to update an object field value in the database if the object exist.
IMongoDatabase db = _mongoClient.GetDatabase(DataBase);
I
The mongoose documentation states in the Options section:
Options:
- ...
- upsert: bool - creates the object if it doesn't exist. defaults to false.
- ...
There should an upsert
parameter, which, if set to true, will create a new object if none was found. However, this defaults to false, so your call should not create a new database entry.
I would assume that the C# driver
should behave identically. If not, you could set the Upsert
parameter to false, see here