Back to Catalog
We introduced the uncle in the package of MONGO warehousing, which introduced a few good curd operations, and for on-demand update of the internal sub-object, it is conditional, that is, your child object can not be null, that is, when we set up the main object, we should assign the initial value to the child object, That is new it, hehe.
The right MONGO collection
For sub-objects that have the initial value assigned, there are two ways to be aware of the following when updating as needed
1 The _id of the child object, if it already exists, updates its value
2 The _id of the child object, if it does not exist, or if it is not displayed as a _id assignment, adds a new record, that is, _id from the newly generated
In the case of an entity update, the value in the entity overrides the value of the original table, and the code that is updated as needed is shown below
#regionUpdate on DemandRepository1. Update<Person> (i =NewPerson {Id="556D531E2683C818C86CADDB", Address=NewAddress {Id="556d531e2683c818c86ca123",/*no ID (or ID not present in the collection) is the addition of an element to the list, the ID exists to update the specified element*/Province="Luanxian", City="111 Hunan Occupation Master", District="Community", Seconds=1}, Addlist=NewList<address>() { NewAddress {/*no ID (or ID not present in the collection) is the addition of an element to the list, the ID exists to update the specified element*/Id="556d531e2683c818c86cadde", Province="Luanxian", City="Hunan occupies master ddd", District="Community", Seconds=1 }} }); #endregion
For the whole update, the same problem, of course, if you need to get the table records from the library
#regionFull updatevare1 = Repository1. Find ("556D531E2683C818C86CADDB"); E1. Name="Wet"; E1. Address.city="Beijing 123"; /*iterate through the original collection, bulk assign values*/E1. Addlist.foreach (i={i.city="Big Account"; }); /*assign a value to each object individually, without specifying an ID that is automatically generated*/E1. Addlist=NewList<address> { Newaddress{city="was accounted for 1"}, Newaddress{city="was accounted for 2"} }; Repository1. Update (E1); #endregion
For Monodb we still need to continue to explore, research ...
Back to Catalog
MongoDB Learning Notes ~ Self-encapsulated curd operations (prerequisites for on-demand updates)