Today to everyone apologized, did not update MongoDB Quick start of the next article, recently a little busy, here to the Bo friends apologize. Below I will briefly describe some of the basic commands of mongdb and some of the problems in our daily development process. MongoDB can provide us with a database to store data, currently in the major training institutions will have about 1 days of the course to explain, while in the actual hair we have to store data and file requirements, we need to understand the background data storage and provide the data interface, and how to obtain data, parse the data, That is, we often say that the front-end interaction, data access and other operations, first we start the MONGDB server.
MongoDB Server-initiated command Window method:
In the corresponding installation of the MongoDB directory new folder "Data" to save data, "" "Press and hold" shift+ right click ", select" Open Command Window Again "as shown in:
Click here to select shift+ right mouse button:
In the Command window: Enter the CD Bin (the main demo is under the Window System)
Continue input: mongod-dbpath= "D:\mongo\data"
The last line of code tells us that the server port is on port 27107.
Let's then reopen a command window to connect to the server:
Under the corresponding root directory file: Enter MONGO:
Here we can learn simple database operations: As a small white, if you do not know what commands, then you can enter help to assist you to view.
MongoDB Data Simple command operation
1.help Query
2. Querying the Database show DBS
3. Use the database using the database name
4. Collections in the database show collections
5. Creation of collections
There are two ways of creating a collection:
1) explicitly created,db.createcollection (' collection name ')
2) Implicit creation, which is automatically created when inserting a document
Note that the quotation marks can not be removed yo!
Note that this is the automatic creation of the collection while inserting the document
Book1 is implicitly created
6. Collection Delete DB collection name. Drop ()
The return result is true
7. Insert the document DB. Collection name. Insert ({property Name: Property value})
8. Query Document: Db.book1.find ()
9. Document deletion: Db.book1.remove ({"Name": "Tom"})
10. Documentation Update: Db.book1.update ({},{})
11. Create a Database
Implicitly creating use DB
Db.c.insert ({name: "DB"})
12. Database Delete Db.dropdatabase ()
Db.dropdatabase ()
These are simple commands to share with you the node. JS operation MongoDB Database and database query in a few days.
Front-end development small white must-learn skills-non-relational databases and MongoDB QuickStart commands like relational databases (2)