Implement Group query for MongoDB under the same vue

Source: Internet
Author: User
Tags install mongodb mongodb query

We know that MongoDB is a non-relational database, so its query method is very different from the standard Structured Query Language SQL. But no matter how complicated it is, when it passes through the developer's hands, it can only become the structure that the customer wants. Today, we are going to talk about how to query Group queries of MongoDB in MongoVUE.

MongoVUE Query format:

Db. collection. group ({key, reduce, initial, [keyf,] [cond,] finalize })

From the above, we can see that to implement grouping query for MongoDB, key (grouping field), cond (grouping condition), refuce (grouping calculation method), and initial (initial condition) is an indispensable value for querying MongoDB groups. Next, let's take a look at how to implement the grouping query function of MongoDB in MongoVUE:

(1) Select the table to be grouped and select "Collection -- Group" to enable the grouping function.

(2) enter the fields to be grouped under the Key, and enter the grouping filtering Conditions under Conditions. Open the ReduceTab page and enter "{" count ": 0}" in the Initial Value field. Enter the following in the Reduce function:

FunctionReduce (doc, out ){

Out. count + = 1

}

Select GO to display the MongoDB group results.

(3) In Shell, the MongoDB query statement is automatically output.

Db. EQUIPMENT. group ({
Key :{
"EquipType": true
},
Cond :{
"SiteId": "Beijing"
},
Initial :{
"Count": 0
},
Reduce: function Reduce (doc, out ){
Out. count + = 1
},
Finalize: function Finalize (out ){
Return out;
}
});

MongoDB details: click here
MongoDB: click here

MongoDB backup and recovery

CentOS compilation and installation of MongoDB

CentOS compilation and installation of php extensions for MongoDB and mongoDB

CentOS 6 install MongoDB and server configuration using yum

Install MongoDB2.4.3 in Ubuntu 13.04

How to create a new database and set in MongoDB

MongoDB beginners must read (both concepts and practices)

MongoDB authoritative Guide (The Definitive Guide) in English [PDF]

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.