monogoDB introduce the use:

monogoDB introduce the use:
Distributed file storage database, developed in C ++, can store any data (files), allowing the server side script, stored data using json {key: value}
The basic terminology: Database - "collection -" Document - "field
There can be multiple databases
View all databases show dbs
Switch to use admin database admin
db current database
 
System database:
admin: equivalent to the root database is a database of high authority, all of the commands can be executed in the library
local: a collection of local server storage
config: related to the fragmentation of the database
 
Support for popular programming languages:
Use db represents the current database
Common name:
db.users.find (). pretty () to view the collection of all data users
Create a database: use the database name - if there is to switch databases, not create
Delete the database: db.dropDatabase () to remove the current database used directly, or add "database name" in brackets
Delete Collection: db.collection.drop ()
Create Collection: db.createCollection (name, option) --options is an optional parameter to specify options for memory size and index
Insert the document: db.collection_name.insert (document) such as:
db.col.insert ({title: 'MongoDB Tutorial'
    description: 'MongoDB is a database Nosql',
    by: 'rookie tutorial'
    url: 'http://www.runoob.com',
    tags: ['mongodb', 'database', 'NoSQL'],
    likes: 100})
Update documents: update () method: db.collection.uppdate ()
Delete the document: db.collection.remove ()
Query document: db.collection.find (query, projection)

Guess you like

Origin www.cnblogs.com/yyhfirstblog/p/11768257.html