MONGO Study 1

Source: Internet
Author: User

About the benefits of MongoDB, advantages and so on here is not said, the only thing to say is that MongoDB has ternary: Database, collection, document, where "collection"

is "table" in the corresponding relational database, "document" corresponds to "row".

One: Download

On the MongoDB official website, we found that there are 32bit and 64bit, this depends on your system, but here are two points to note:

①: According to the industry rules, even "stable version" (such as: 1.6.x,1.8.x), odd for "development version" (such as: 1.7.x,1.9.x), the difference between the two versions I believe everyone knows it.

②:32bit MongoDB can only store 2G of data, 64bit there is no limit.

I will download the "2.0.2 version, 32bit", OK, after downloading I put the "e-Disk", change the folder name "MongoDB".

Two: Start

①: Before starting, we will assign a folder to MongoDB, which is named "DB", which is used to store mongodb data.

②: Microsoft logo +r, enter CMD, first find the "MongoDB" path, and then run the Mongod Open command, while using--dbpath to specify the data storage location is "DB" folder.

③: Finally to see whether the open success, the information learned that MongoDB uses 27017 port, then we will type "http://localhost:27017/" in the browser,

After opening, MongoDB tells us that on 27017 add 1000 can view MongoDB's management information in HTTP mode.

Three: basic operation

Because it is the beginning, about the basic "additions and deletions to change", we open a cmd, enter the MONGO command to open the shell, in fact, this shell is the client of MongoDB,

Also is a JS compiler, the default connection is the "test" database.

<1> Insert Operations

Well, the database has, the next step is the collection, here to take the collection named "Person", note that the document is a JSON extension (Bson) Form.

<2> Find operations

After we insert the data, it is definitely to find out, or plug in the white plug, here to pay attention to two points:

① "_id": This field is the GUID that the database gives us by default, the purpose is to guarantee the uniqueness of the data.

② strictly in accordance with the Bson form of the document, but it doesn't matter, the error is very powerful.

<3> Update operation

The first parameter of the Update method is "find condition", the second parameter is "updated value", and learning C #, I believe it is well understood.

<4> Remove operation

Remove if no parameters will delete all data, oh, very dangerous operation, in MongoDB is a non-revocable operation, think twice before the line.

MONGO Study 1 (turn)

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.