Summary of mongodb Learning (1)
About the default setting of mogodb database: 1. The default port setting is: 270172. The default location of the database file is: c:/data/db. It is recommended to modify it to another disk location. You must create a data/db folder in the root directory of the disk. The default log recording method of 3.mongodb database is to rewrite or overwrite. It is recommended to use additional logging method: mongod-- logpath "d:/data/log/mongodb.log"-- logappendmongo shell operation command: 1. Connect to mongoDB database mongo-- host hostname/ip-- port 27017 [databaseName] example: mongo-- host 172.0.0.1-- port 27017 mydbs2. The collection operation db.student.drop (); / / deletes the collection student 3. Key points of document operation: understand the $inc/$set/$unset/$push/$pop/upsert modifier / / insert the document db.student.insert ({"name": "zhangsan"}) into the student collection; / / query the document using find (); db.student.find (); / / update the id=58d4ccd4126ab1e4ca76aa73 document, modify or add its name key pair db.student.update ({"_ id": ObjectId ("58d4ccd4126ab1e4ca76aa73")}, {"$set": {"name": "xiaoming"}}) / / modify the document using update () db.student.update ({"name": "xiaoming"}, {"$set": {"age": 23}}); db.student.update ({"name": "xiaoming"}, {"$set": {"name": "Jackie Chan"}}) Result: {"_ id": ObjectId ("58d4ccd4126ab1e4ca76aa73"), "name": "Jackie Chan", "age": 23} / / format the document db.student.find () .pretty () {"_ id": ObjectId ("58d4ccd4126ab1e4ca76aa73"), "name": "xiaoming", "age": 23} / / delete document syntax: db.collection.remove (condition, {justOne:, writeConcern:}) query: (optional) conditions for deleted documents. JustOne: (optional) if set to true or 1, only one document is deleted. WriteConcern: (optional) the level at which the exception is thrown. For example: db.student.remove ({"name": "Jackie Chan"}, {"justOne": true, "writeConcern": true}); 4. Conditional operators $lt (), $gte (> =), $lte (