I am new to developing with Mongo and I took the 320 Data Modeling class. I then went on to take the M220N MongoDB for .Net developers class… While the classes were good… There are some specific questions that I never could get a handle on.
I am building an application for an E-Commerce site and in this application, I need to update Products… My question is that I ultimately would like to work off of the Object model… If I call the product in as an object, I get access to all of the traits associated with that object (Name, Short Description, Long Description, Etc).
My question centers around passing the object to the UpdateOneAsync or ReplaceOneAsync function… If I were to pass UpdateOneAsync(product, cancelationToken), would I update all fields in the product object, or do I need to unwind the object first?
The M220N class deals with the .Net development, but the operation of new BsonDocument(“fieldName”, value) isn’t explained at all… So… My question is, Do you need to always use the new BsonDocument in ANY or ALL update or replace operations?
I hope I explained this well enough…
Also… According to the MongoDB Documentation… If updating several fields, it recommends using the ReplaceOneAsync method… Does this replace the _id field also? Or does it just replace the fields in the document?