Use MONGO's own shell command at the command line to perform CRUD operations
First link to database
Increase
Db.qiao.insert ({"QQ": 1})
Db.qiao.save ({"QQ": 3})
Db.qiao.save ({"_id": ObjectId ("5721461f5b4e77bbbae66982"), "QQ": 100})
The difference between save and insert
Insert can only insert data, but it can insert data from a list
Save if you have this data in the database to perform the modification operation, if you do not have this data to perform the insert operation
Insert efficiency is higher than save
By deleting
Db.qiao.remove ({"QQ": 3}) Delete data based on criteria
Db.qiao.remove () Removes the entire document, but does not delete the structure of the document
Db.qiao.drop () Delete the entire database, this data is very fast (but it needs to be re-indexed after deletion)
Delete Data is permanent, cannot be undone, and cannot be recovered.
Change
Db.cs.update ({"_id": ObjectId ("571F46E0A7B78ABFA1768EBF")},{z:20}) The simplest modification, before the number is the search parameters, after the modification parameters
Db.cs.update ({"_id": ObjectId ("571F46E0A7B78ABFA1768EBF")},{"$inc": {"Z": 1}})
$inc Z plus 1 This can be used to do statistical things, or the birthday of the time to execute such a command let the age plus a
Db.cs.update ({"_id": ObjectId ("571F46E0A7B78ABFA1768EBF")},{"$set": {"book": "C # Daquan"}})
$SET Specifies the value of a field. If this field does not exist, create it.
Check
Db.cs.find () returns 10 data at a time in the shell
Db.cs.findOne () returns a single piece of data
Db.cs.find ({"Z": 20}) returns data based on query criteria
MONGO executing crud on the command line