1, configuration: Mongod--dbpath=d:\mongodb\data
Mongo
2, the 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 argument is a condition. The second parameter is the modified value, but the value must be an integer. ($inc allowed for numbers only)
$set modifier: db.person.update ({"Name": "Gll"},{$set: {"Age": 25}}}
Another action is to modify or add an operation: This can be called a 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 more than one match is matched, only the first article is updated by default. If more than one update is required, set the fourth parameter in update to TRUE. is also very simple.
Remove operation.
3. Advanced operation
Polymerization:
Count () distinct () which property is selected, which cannot be duplicated.
Group () parameter key: Specifies the basis on which the document is grouped, the values of all age keys are divided into one group, and true to return the value of the key age.
Initial: "initial": {"person": []} The initial number of reduce function calls per group, all members of the first group will use this accumulator.
Plainly. This is an initial value. This value is invoked at each $reduce to change the value.
Example:
Db.person.group ({
. ' key ': {' age ': true},
. "Initial": {"person": []},
. $reduce: Function (Cur,prev) {The first argument is the current document, and the second parameter is the 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:}
}