About the benefits of MongoDB, advantages and so on here is not said, the only thing to talk about is the MongoDB: Database, collection, document, where "set"
is "table" in the corresponding relational database, and "document" corresponds to "line".
One: Download
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 industry rules, the even number is "stable edition" (such as: 1.6.x,1.8.x), the odd number is "development version" (such as: 1.7.x,1.9.x), the difference of these two versions believe everybody knows.
②:32bit MongoDB can only hold 2G of data, 64bit there is no limit.
I download the "2.0.2 version, 32bit", OK, download after I put to "e disk", changed the folder name "MongoDB".
Two: Start
①: Before we start, we need to assign a folder to MongoDB, named "DB", to hold the MongoDB data.
②: Microsoft logo +r, input cmd, first find the "MongoDB" path, and then run the Mongod to open the command, with the--dbpath to specify the data storage location for the "DB" folder.
③: Finally to see if the success of the open, from the information in the figure, MongoDB using 27017 ports, then we will type in the browser "http://localhost:27017/",
After opening, MongoDB tells us that on 27017 add 1000 can view MongoDB Management information in HTTP mode.
Three: basic operation
Because it is the opening, it is probably the next basic "additions and deletions", we open a cmd, input MONGO command open shell, in fact, this shell is MongoDB client,
Also is a JS compiler, the default connection is the "test" database.
<1> insert Operation
Well, the database has, the next step is the collection, where the collection named "Person", to note that the document is a JSON extension (Bson) Form.
<2> Find operation
We will be inserted into the data, it is definitely to find out, or inserted into the white plug, here to pay attention to two points:
① "_id": This field is the GUID that the database adds to us by default, the purpose is to guarantee the uniqueness of the data.
② strictly in the form of Bson writing documents, but it does not matter, the wrong hint is still very powerful.
<3> Update operations
The first parameter of the Update method is "criteria to find", and the second parameter is "updated value", and I believe it is very well understood by learning C #.
<4> Remove operation
Remove all data without parameters, oh, very dangerous operation, in the MongoDB is an irrevocable operation, think twice before you do.