This post consists of: http://xinpure.com/2015/01/07/codeigniter-mongodb%e6%89%a9%e5%b1%95%e4%b9%8b%e4%bd%bf%e7%94%a8aggregate% e6%96%b9%e6%b3%95%e5%ae%9e%e7%8e%b0mysql%e7%9a%84sum%e6%96%b9%e6%b3%95/CodeIgniter MongoDB extension using aggregate to implement the Sum method
Here's Codeigniter MongoDB an extensio
) {# After the last grouping, a result is obtained, then the result is processed}}); Handling AvgDb.collection.group ({key:{category:1}, # classify cond:{shop_price:{$GT according to Category:20}}, # Additional conditional commodity borrow a commodity greater than 20 reduce:function(Curr, result) {# Curr identifies a row of records, a result-custom variable, Result.count+ = 1; Result.total+=parsefloat (Curr.shop_price); }, Initial:{total:0,count:0,avg:0}, # Initialize variables, variables define
This article introduced the MongoDB in the MapReduce implementation of data aggregation method, we mentioned MongoDB in the data aggregation operation of a way--mapreduce, but in most of the day-to-day use of the process, We do not need to use MapReduce to do the operation. In this article, we simply talk about the implementation of the data aggregation operation with the aggregation function.
In addition
Label:in the two previous articles the basic aggregation function of data aggregation in MongoDB count, distinct, group > and the MapReduce of data aggregation in MongoDB >, we've provided two implementations for data aggregation, and today, in this article, we talk about another way to implement data aggregation in MongoDB-the aggregation pipeline
consecutive $skip will be merged into one, followed by a number of two $skip.Two consecutive $match. are merged into 1, the conditions are merged together.{$sort: {Age:-1}},{$skip: 10},{$limit: 5}{$sort: {Age:-1}},{$limit: 15}{$skip: 10}Example{$sort: {Age:-1}},{$skip: 10},{$limit: 5}====>>>>{$sort: {Age:-1}},{$limit: 15}{$skip: 10}====>>>>$sort + $limit Merge{$limit: 100},{$skip: 5},{$limit: 10},{$skip: 2}==========>>>>>>>{$limit: 100},{$limit: 15},{$skip: 5},{$skip: 2}=========>>>>>>>>>{$limi
Tags: MongoDB aggregate multiple grouping conditionsWhen using aggregate for grouping, multiple grouping conditions are as followsNative sql:Db.test.aggregate ({$group: {_id:{name: ' $name ', Pro: ' $pro},total:{$sum: ' $num '}}},{$project: {Total:1}})In Java, this corresponds to the following:Grouped according to Subjname and province
dbobject groupfields = new
inserting insertThe data structure of the MongoDB document is basically the same as JSON. All data stored in the collection is in the Bson format. Bson is a binary form of a class JSON storage format, referred to as binary JSON.First we select the databaseLet's define a document firstThen we go into today's topic, insert a document into the collection, insert it in two ways, one is to insert a defined document, and the other is to insert undefined dat
Tags: style blog http io os ar java for SPJava Operation MySQL Database code we have a very familiar, and additions and deletions, Java to the MongoDB database is similar to the operation, first database connection, and then the operation.First we enter into the admin database, and then set up their own database Testmongodb, access to the admin database, you can directly into the TESTMONGODB, because the user can enter the system database, is super Ad
MongoDB uses find to query, returning a subset of the documents in a collection;Returns all documents in the Document collection blog:> Db.post.find () {"_id": ObjectId ("54a530c3ff0df3732bac1681"), "id": 2, "name": "Joe", "age": +, "sex": 1, "SCHool ":" Marry "} {" _id ": ObjectId (" 54a530c3ff0df3732bac1680 ")," id ": 1," name ":" Joe "," age ": +," comments ": [ "Test2", "Test9", "Test5"], "sex": 1, "sch
Tags: cat article can't share mon cti waiting Ges TipsWhen you install MongoDB, use MongoDB as the system service to start the net start MongoDB, error occurs system errors 2 The system cannot find the file specified. The reason for this is because the executable file address of the system service is incorrect. Modify
MongoDB was used in a recent project, mostly using MongoDB's PHP extension. The method used in MongoDB extensions for a query is find (). Here's a simple note for the experiment in understanding the MongoDB extension's find () method, and hopefully to help others.In a
Format find () in the MongoDB command line and return the result: pretty () db. collection. find (). pretty (); www.2cto.com to add a permanent method, execute the following code in shell echoDBQuery. prototype. _ prettyShelltrue ~. Mongorc. js is pretty () anytime, anywhere.
Format find () in the
MongoDB Query Find(2012-01-05 11:38:10)reproduced
Tags:it
Category: MongoDB
MongoDB Query FindSpecifies the key to return, specifying the desired key through the second parameter of Find or FindOne.> db.visithomepage.find ({},{"user_i
Label:intends to write a blog system with Nodejs, found that Nodejs still exist a lot of pits. The following error question was encountered when using MongoDB: {[Error:cannot find module '. /build/release/bson '] Code: ' Module_not_found '}
js-bson:failed to load C + + Bson extension, using pure JS versionToss it over, and finally it's settled like this: Find
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.