Group Group query for MongoDB implemented under Mongovue

Source: Internet
Author: User
Tags mongodb mongodb query

We know that MongoDB is a kind of relational database, so its query method is very different from the standard Structured Query language SQL. But no matter how complicated a structure it is, when it passes through the developer's hands, it only becomes the structure that the customer wants. Today is about how to MongoDB group group queries under Mongovue.

The Mongovue query format is as follows:

Db.collection.group ({key, reduce, initial, [Keyf,] [Cond,] finalize})

From the above, we can see that to implement the MongoDB group query, key (Group field), cond (group condition), Refuce (group calculation method), initial (initial condition) is MongoDB packet query is not less than the value. Next, we will look at how to implement the MongoDB query function under Mongovue:

(a) Select the table to be grouped, select "Collection--group", and turn on the grouping feature.

(b) Under Key to enter the field to be grouped, conditions under the input packet filter conditions. Open Reducetab page, initial value out input "{" Count ": 0}", below reduce function to enter:

Functionreduce (Doc, out) {

Out.count +=1

}

Select Go, which is the group result that pops up the MongoDB.

(c) At the shell, the MongoDB query is automatically typed.

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;
}
});


--This article from: http://www.linuxidc.com/Linux/2014-03/98217.htm


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.