I recently started to read some articles about MongoDB.ArticleMore and more think that it is what I need. However, I know very little about it first. I can see that it is a superficial phenomenon.
I started reading the MongoDB introduction written by Karl yesterday. There are 33 pages in total. I feel that this article is not very clear and I need to try and understand it myself.
For traditional databases, crud (= create + read + update + Delete) is the core, and U is the most noteworthy! Let's take a look at the update part and practice it.
Update has four parameters: first, selector, second, newvalue, third, upserts, fourth, and multipleupdate.
Like CRD, selector is a search selector that clarifies the query conditions;
Newvalue is the content to be updated. There are two basic conditions: $ set, $ Inc, and $ push:
Scenario 1: If there is no parameter, newvalue replaces the content of the original selector;
Scenario 2: With parameters, $ set is to update newvalue for the specified field; $ Inc requires that the specified field be a numerical value and the value of newvalue; $ push requires that the specified field be an array, add newvalue to the array. Of course, there must be a lot of parameters, so I will only learn so much!
I will not expand it. I will repeat it again.CodeYou will know what it means;
Upserts is a logical value parameter. The default value is false. That is, if the document is queried Based on selector, the update is executed. If no information is found, nothing is done. If it is set to true, the meaning is obvious. If it is not found, create a new document to store selector and newvalue.
Multipleupdate is also a logical value parameter. The default value is false. That is, the first document is updated when the parameters are found based on the selector query. If the value is set to true, update all the retrieved documents.
Two MongoDB entry notes
Fields vs. Columns
MongoDB 1st step