Home>

mongodb is currently a very popular non-relational database (nosql), because of its simple operation, completely free, open source code, etc.It is favored by IT practitioners,And is widely deployed in actual production environments.This article teaches you 8 days to learn mongodb-the first day of basic introduction,Interested friends come to understand

Regarding the benefits of mongodb, the advantages and the like are not mentioned here,The only thing to talk about is that there are three elements in mongodb:database, collection, document, where "collection"

It corresponds to the "table" in the relational database, and the "document" corresponds to the "row".

1:Download

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

①:According to industry rules,Even numbers are "stable versions" (such as:1.6.x, 1.8.x) and odd numbers are "development versions" (such as:1.7.x, 1.9.x). I believe everyone knows the difference between the two versions.

②:The 32-bit mongodb can only store 2g data at most, and the 64-bit is unlimited.

I will download the "2.0.2 version, 32bit" here, ok. After downloading, I will put it on "e-disk" and change the folder name to "mongodb".

2:start

①:Before starting,We are going to specify a folder for mongodb,It is named "db" here to store mongodb data.

②:Microsoft logo + r, enter cmd, first find the path of "mongodb", and then run the mongod start command,Also use --dbpath to specify the data storage location as the "db" folder.

③:Finally, it depends on whether it is successfully opened.From the information in the picture,mongodb uses port 27017, then we type "http://localhost:27017/" in the browser,

After opening, mongodb tells us that add 1000 on 27017 can view mongodb management information in http mode.

Three:Basic operations

Since it is the beginning,Generally speaking, the basic "add, delete, check and change", we open another cmd, enter the mongo command to open the shell, in fact, this shell is the client of mongodb

It is also a js compiler,The "test" database is connected by default.

<1>insert operation

OK, the database is there,The next step is collection,Here the collection name is "person". It should be noted that the document is a json extension (bson) form.

<2>find operation

After we insert the data,It must be found, otherwise it will be inserted in vain,There are two points to note here:

① "_id":This field is the guid added to the database by default, the purpose is to ensure the uniqueness of the data.

② write documents strictly in the form of bson,But it doesn't matter,Error prompts are still very powerful.

<3>update operation

The first parameter of the update method is "find condition", and the second parameter is "updated value". I have learned c#and believe it is still well understood.

<4>remove operation

remove without parameters will delete all data,Ha ha, very dangerous operation,Is an irrevocable operation in mongodb,Think twice.

  • Previous Analysis of ASP Error Object Knowledge
  • Next JS picture thumbnail with carousel effect code sharing