I want If document exists Update only one property, If does not exist insert a document not only with one property (with all properties) in mongo,
for example:
var customer = new Customer
{
Name="David",
Family="Green",
CustomerId="12",
Gender="male"
};
var filter = Builders<Customer>.Filter.Where(s => s.CustomerId == customer.CustomerId);
var updateDefination =
(Builders<Customer>.Update.Set(s => s.Name, customer.Name));
var options=new UpdateOptions
{
IsUpsert = true,
};
MongoHelper.GetCollection<Customer>().UpdateOne(filter, updateDefination,options);
How can I say if Customer with that id does not exist, insert customer object with all that properties.