How MongoDB is used

Source: Internet
Author: User
Tags json mongodb
Data persistence: Persistent Data persistence method: 1. File read/write 2.cookie, server stored in the client's data, the client will automatically send the cookie to the server (the cookie is stored in the HTTP header), Session + Cookie 3.
Localstorage, client local storage 4. Database Note: formatted string: json,xml mysql: relational database, tables and tables can be associated (primary key, foreign key, index); operation on relational database, general use of SQL (Structured query statement) MongoDB: Non-relational database, supporting the processing of big data, clustering (multiple servers connected together), distributed (the location of the server is not the same) relational non-relational database Database table collection Field field installation command: Brew INS Tall MongoDB Test Installation Successful command: Mogon appears version number MongoDB uses 1. Enter MONGODB Environment command: MONGO NOTE: The test database is connected by default, and you can create a database 2 yourself if you do not have a connection. New MONGONDB Database command: Mongod--dbpath folder path 3. In a MONGO environment (>), display all database commands: Show DBS 4. Switch database command: Use database name NOTE: When the database does not exist, and the database Operation to create a new database 5. New Collection Command: Dbcreatecollection (' collection name ') crud operation: Add (Create) Delete (delete) change (Update) (retrive) 6. Query command: DB. Collection name. Find () 7. Insert command: DB. collection name. Insert (data) Note: When the inserted collection does not exist, add one to the new collection for example: Db.student.insert ({name: ' Show ', Gender: ' Male ', age:18}) to add multiple lines for example:
Db.student.insert ([{name: ' Alice ', Gender: ' Female ', Age: '},{name ': ' Xiao Hong ', Gender: ' Female ', Age: ' 19 '}]) Note: The structure of an ID data is automatically added must be Bson Bson:binary JSON, a JSON-like binary data, like the JSON structure ({}: Document object, []: Array object), more than the data type supported by JSON (DATE,BINDATE) Note:The structure of the inserted data can be different 8. Displays the collection command in the database: Show Collections 9. Delete the collection db. Collection name in the database. Drop () 10. Modify Data command: DB. Set name. Update (query condition, modified content, optional parameters) Modify a data example: Db.student.update ({name: ' Alice '},{$set: {name: ' Xiao Yu '}}) modify multiple data db.student.update ({name: ' Xiaohong '},{$set: {name: ' Xiao Xiao ') }},{multi:true}) 11. Delete Data command: DB. Remove multiple data (query condition, optional parameter) For example: Db.student.remove ({name: ' Xiao Yu '}) delete a data such as:
 Db.student.remove ({name: ' Xiao Xiao '},{justone:true}) visualization of the operating software: Robomongo
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.