1, configuration: Mongod--dbpath=d:\mongodb\data
Mongo
2, basic additions and deletions to check and change
Find () Update ()--Overall update, local update.
Modifier: $inc db.person.update ({"Age": 23},{$inc: {"Salary": 1000}})
The first parameter is a condition. The second parameter is a modified value, but the value must be an integer. ($inc allowed for numbers only)
$set modifier: db.person.update ({"Name": "Gll"},{$set: {"Age": 25}}
There is also an action to modify or add an action: This can be called insertorupdate operation.
Just set the third parameter of update to TRUE. If not, just add a new one in the database to avoid the database to determine whether the update or add operation. Easy to use.
Batch update:
If you match more than one, only the first one is updated by default. If more than one update is required, set it to true in the fourth parameter of update. Also very simple.
Remove operation.
3. Advanced operation
Polymerization:
Count () distinct () which property is selected and which cannot be duplicated.
Group () parameter key: Specifies the basis for grouping documents, all the values of age keys are divided into a set, and true is the value of the return key age.
Initial: "initial": {"person": []} The initial number of each set of reduce function calls, all members of the first group will use this accumulator.
Plainly. This is an initial value. Each time $reduce calls this value to change the value.
Example:
Db.person.Group({. "Key": {" Age ": true},." Initial ": {" person ":[]},. "$reduce":function(Cur,prev) {The first parameter is the current document and the second parameter is an accumulator document. Prev.person.push (Cur.name);. }. }) Eg:db.person.Group({"Key": {" Age ": true}," initial ": {' person ':[]}, "$reduce":function(doc,out) {Out.person.push (doc.name);}, "Finalize":function{out] {out.Count=out.person.length;}, "condition": {"age": {$lt: -}}