Here we will not talk about the advantages and advantages of mongodb. The only thing we need to talk about is that mongodb has three elements: database, set, and document, where "set"
Is corresponding to the "table" in the relational database, "document" corresponds to "row ".
I. Download
On the official MongoDB website, we found that there are 32bit and 64bit, which depends on your system, but here are two points of attention:
①: According to industry rules, the even number is "stable version" (for example, 1.6.X, 1.8.X), and the odd number is "development version" (for example, 1.7.X, 1.9.X ), I believe everyone knows the difference between the two versions.
②: 32-bit mongodb can only store up to 2 GB of data, and 64bit is unlimited.
Here I will download "2.0.2, 32bit", OK. After the download, I will put it on the "edisk" and change the folder name to "mongodb".
Ii. Start
①: Before starting, we need to specify a folder for mongodb, named "db" here, to store mongodb data.
②: Microsoft logo + R, Enter cmd, first find the path of "mongodb", then run mongod to enable the command, and use -- dbpath to specify the data storage location as the "db" folder.
③: Check whether it is enabled successfully. The information shows that mongodb uses port 27017. Then, type "http: // localhost: 27017/" in the browser /",
When mongodb is enabled, we can view mongodb management information in http mode by adding 27017 on 1000.
III. Basic operations
Since it is the beginning, we will probably say the basic "add, delete, query, modify". Let's open another cmd and enter the mongo command to open the shell. In fact, this shell is the mongodb client,
It is also a js compiler that connects to the "test" database by default.
<1> insert operation
Well, the database has a set. The next step is the set. Here, the set name is "person". Note that the document is in the form of json extension (Bson.
<2> find operation
After we insert the data, we must find the data. Otherwise, the data is inserted in white. Here, we should pay attention to two points:
① "_ Id": this field is the GUID that the database adds by default. The purpose is to ensure data uniqueness.
② Writing documents in strict Bson format does not matter, and the error prompt is still very powerful.
<3> update operation
The first parameter of the update method is "Search Condition", and the second parameter is "update value". I have learned C # and believe it is quite understandable.
<4> remove operation
If no parameter is included in the remove operation, all data will be deleted. It is a very dangerous operation. It is an irrevocable operation in mongodb. Think twice before you proceed.