MongoDB is a distributed file storage database, note these two words, distributed and file storage. MONGODB supports replication and sharding, can reasonably use the size of space, can also achieve the purpose of disaster tolerance. In addition file storage is also a feature, abandoned the traditional table concept, using the concept of the set, the following is the corresponding diagram
Another MongoDB has the advantage of having a JavaScript shell, where you can use the pure JS syntax.
The current MongoDB version is 3. Version of the X, its API relative to the 2.x version of a lot of changes, including a lot of commonly used additions and deletions to change the command has changed.
First, download MongoDB, and then CD into its bin directory. Start a MongoDB instance as shown in.
As shown, the started MongoDB instance automatically listens on port 27017.
Open a cmd again and enter MONGO into the shell.
Here are a few basic commands ————
Show DBS shows all databases
DB Displays the current database
Use test03 uses the test03 database, and no new one is created.
Then create a new collection, insert a piece of data into it, and Insertmany can insert multiple data in the 3.x version.
This is an increased operation, we add two more, and then look at it.
We see that there are three records in it, and find can pass in a parameter for filtering operations such as:
The document with ID 2 was found first, and then all documents with an ID of less than 3 were found. There are so many things like $lt, such as $GT, $lte, $gte, $eq, $or, $in, $nin, and so on, that can be filtered. In addition, input the following parameter can filter the output field, 0 is not displayed, 1 is displayed, filtered out the _id field. Of course, you can also change the data.
, change the document with ID 3 to the document with ID 4. The $set is set, and the $inc is the number's self-increment.
In addition, finally there is a delete command, this time we have the ID 2 of the document deleted.
Well. There are only two documents left. And, of course, there's a deletemany command that can delete more than one piece of data.
In addition, there is a small trick, you can directly hit the command name in order to obtain information related to the command.
Yes, it works. This is the installation of MongoDB and the increase and deletion of the search, back to continue the other.
MongoDB installation and increase and deletion check