- 
                Notifications
    You must be signed in to change notification settings 
- Fork 141
How to do groupby
        ichikaway edited this page Apr 21, 2011 
        ·
        2 revisions
      
    <?php
   $query = array(
        'key' => array('title' => true ),
        'initial' => array('csum' => 0),
        'reduce' => 'function(obj, prev){prev.csum += 1;}',
        'options' => array(
          'condition' => array('count' => array('$lt' => 5)),
          ),
        );
    //$this->Post is Model.
    $mongo = $this->Post->getDataSource();
    $result =  $mongo->group($this->Post, $query);