MongoDB (3)-add, delete, modify, and query operations

Source: Internet
Author: User

MongoDB (3)-add, delete, modify, and query operations

MongoDB, as a non-relational database, is very different from the addition, deletion, modification, and query of traditional databases. Here we only outline the knowledge points. In actual use, we can use Baidu for details. Let's take a look at several major aspects:




I. There are relatively few knowledge points for insertion and deletion. First, let's take a look at the updates. Common operations are still very useful. We need to use them flexibly according to the actual situation. Here we only put forward knowledge points, and we need Baidu's example to learn how to use them:




2. The same is true for queries. Let's take a look at the summary of knowledge points. In fact, there are still a few regular queries, which are easier to record:




3. Take a look at the fixed set Capped Collection: as the name suggests, it is a set with a fixed size, its advantage is that the performance is excellent, with LRU (Least Recently Used) rule and insert sequence for age-out (aging removal) processing. Because the size of the set space is certain, when the space is used up, the newly added object will replace the oldest object in the set and keep the latest object forever.

Features: The insertion speed of a fixed set is extremely fast; the query output speed is extremely fast according to the insertion order; the earliest data can be eliminated when the latest data is inserted.

Usage: stores log information, which is best suited for caching a small amount of documents ......

Create: db. createCollection ("my_collection", {capped: true, size: 100000 })

Convert a common set to a fixed set: db. runCommand ({convertTocapped: "test", size: 100000 })

 

 

4. Large file set (GridFS ):

GridFS is a mechanism for storing large binary files in MongoDB, such as storing large files, such as videos and HD images. GridFS directly uses the established replication or sharding mechanism, fault recovery and scalability are both easy; users can avoid file system problems when uploading content; it will not produce disk fragments.

 

GridFS uses two tables to store data. By default, fs. files: Contains metadata objects, and fs. chunks contains binary blocks of file-related information. You can use the program files in the bin directory to perform the put (storage), get (get), and list (list) commands. Very simple.

 

 

Okay, let's just briefly talk about the addition, deletion, modification, and query of MongoDB. The specific operation instance is not provided and can be checked in time. We need to know these things, fixed sets and large file sets, which are very good ideas, it deserves our special attention. I suddenly thought of the previous series of pictures and thought about it. It seems that it can also be done here. Just look at these pictures and tell them all. This is almost the case.



Related Article

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.