Convert MongoDB console aggregate to php with array -


i failing convert following mongodb console command:

db.customers.aggregate( [ { $group : {     _id: {         year : { $year: "$since" },                 month : { $month: "$since" }     },     count: { $sum: 1 } } }] ); 

which works php

$customers->aggregate(array(     '$group' => array(         '_id' => array( 'year' => array('$year' => '$since'),                         'month' => array('$month' => '$since')             )         ),         array(             'count' => array( '$sum' => 1 )             ),         )     ); 

which returns exception: pipeline stage specification object must contain 1 field. tried '"$since"' no luck

the count field must part of group.

$customers->aggregate(array(     '$group' => array(         '_id' => array( 'year' => array('$year' => '$since'),                         'month' => array('$month' => '$since')             ),          'count' => array( '$sum' => 1 )         )     )); 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -