MongoDB is written by the C + + language and is an open source database system based on distributed file storage.
In the case of high load, adding more nodes can guarantee the performance of the server.
MongoDB is designed to provide scalable, high-performance data storage solutions for Web applications.
MongoDB stores data as a document and data structures consist of key-value (key=>value) pairs. A MongoDB document is similar to a JSON object. Field values can contain other documents, arrays, and array of documents.
Basic operation:
Remote connection: mongo-u username-p password ip:port/dbname (library name)Show All libraries: Show DBSSelect a library: User dbCreate library: User NewdbnameDelete Library: db.dropdb ()View all collections: Show CollectionsAdd Collection: Db.collection.insert ({"Name", "Hello"}) if the collection does not exist, the collection is automatically created and the data is addedDb.collection.insertOne ({"Key", "value"})Db.collection.insertMany ([{"A", 1},{"B", 2},{"C", 3}])Delete collection: Db.collection.drop ()Empty Collection: Db.collection.remove ({})View collection: Db.collection.find ()Db.collection.find (). Pretty ()Update Collection: Db.collection.update ({"Key": "A"},{$set: {"A": "AAA"}},{multi:true}) is preceded by the Where condition of the update operation, followed by the data that needs to be updated. When there are multiple identical keys in the collection, MONGO only updates the first data, and with {multi:true} You can modify multiple documents of the same keysave ({...}) new features in version 3.2:Db.collection.updateOne ()Db.collection.updateMany () Multi not requiredWhere Condition: equals {key:value}less than {key:{$lt: value}}greater than {key:{$gt: value}}less than or equal to {key:{$lte: value}}greater than or equal to {key:{$gte: value}}not equal to {key:{$ne: value}}and {key1:value,key2:value2}OR {$or: [{key1:value1},{key2:value2}]}Fuzzy query: Db.collection.find ({key:/value/})contains query: Db.collection.find ({key:{$in: [Key,key2]}})does not include query: Db.collection.find ({key:{$nin: {key1,key2} }})de-weight: db.collection.distinct (value) Db.collection.find ({key:{$type: 2}) queries the key for a string type of data paging query Db.collection.find (). Limit (pagenumber). Skip (PageSize)Match data type $type
MongoDB Basic Operations