Document at address: http://download.csdn.net/detail/wyqlxy/3999890
MongoDB is a document-type database, not a relational database. The basic idea is to replace the original "line" concept with a more flexible "document" model. A document-oriented approach can embed a document or array, so a single record can be used to express complex patterns. Generally as a network server.
MongoDB does not have a pattern: the key to the document is not defined beforehand and will not be fixed.
MongoDB is easier to expand. When you need to expand, just add the machine to the cluster and let the database do the rest.
MongoDB has a unique, easy-to-use tool:
1, index. With secondary indexing, queries can be made faster. It also provides unique, composite and geo-spatial indexing capabilities.
2, store JavaScript. Functions and values can be stored directly on the server side.
3, polymerization. Supports MapReduce tools and other aggregation tools.
4, fixed set. The size of the collection is capped.
5, file storage. Supports an easy-to-use protocol for storing metadata for large files and files.
But there are also drawbacks: joint joins and complex multiline transactions.
Although the MongoDB function is powerful, it does not have the function of a relational database. As much as possible, it gives the client the logic of the server (which is handled by the driver or the user's application), which allows the MongoDB to have a good amount of performance.
After the MongoDB is started, there is hardly any necessary operation, and if the primary server is hung up, it will automatically switch to the backup server. And the backup server is upgraded to an Active server.
The core of the document when MongoDB. Multiple keys and associated values are placed together in an orderly manner as a document. The values in the document are not just strings, but other types.
Note: Values cannot contain a. Because this character is used to indicate the end of the key. 2. and $ best not to use 3, the same _ best not. Some of the default keys for the system such as: _index is the beginning of this.
MongoDB not only distinguishes between types, but also case sensitive. Duplicate keys are not allowed in the document.
A collection is a set of documents. If the document in MongoDB resembles a row in a relational database, that collection is a table. The collection is modeless, which means that the type of document in the collection is also varied.
such as: {"firest": "Hello"} {"Seconde": 5}. Their types are different and the keys are different. collection contains child collections. General use. Said. For example: Blog.content and Blog.authors.
MongoDB has a JavaScript Shell and can interact with MongoDB from the command line. It allows you to perform administrative actions and check for running instances. This tool is very important. The shell is the standard JavaScript interpreter. The shell automatically connects to the MongoDB server at startup, so be sure to start the server first and then run the shell. It is a stand-alone MongoDB client. The shell also has some non-JavaScript syntax extensions. Is for the convenience of users of SQL Shell.
1, create
First, create a local variable and related content. Post ={"title": "My Blog", "Content": "This is my blog", "date": New Date ()}
Insert data: Db.blog.indert (POST). After the record is saved, an extra column of "_id" is automatically created.
2, Read
Find returns all the documents in the collection. If you want to see only one, you can also use Findone:db.blog.findone (). Both of these can accept the constraints of the query.
3, Update
Update. He accepts at least two parameters. For example: Modify the post variable to increase the "comments" key
First step: post.comments=[]
Then perform the update operation. Db.blog.update ({title: "My Blog", Post}). Replace the title my blog document with the new version of the document.
4, delete
Remove. It can accept parameters. Permanently delete data. Db.blog.remove ({"title": "My Blog"}). If no arguments are added, all documents within the collection are deleted.
If you are looking at database-level help, you can use Db.help (). One technique for understanding a function is to not enter parentheses when typing, so you can see how the function's JavaScript function is implemented.