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]