change mongoClient Query into \MongoDB\Driver\Query

2 views
Skip to first unread message

Rakesh Pandey

unread,
Oct 23, 2018, 8:06:08 AM10/23/18
to xamp...@googlegroups.com
Hi Group,
I am using mongodb
$query = new \MongoDB\Driver\Query($filter,$options);
I want to use grouping and sorting with above query.
could anybody tell me whether it is part of $filter or $Options.

Regards

Rakesh Pandey
 09015461092 
  


Rakesh Pandey

unread,
Oct 24, 2018, 4:28:03 AM10/24/18
to xamp...@googlegroups.com
Hi
 I found the way but group option is not working.We use group, sort, projection all inside $options.

$query = new \MongoDB\Driver\Query($filter,$options);
$filter = [
        'name' => "rakesh",
        'distributor_id' => 8
    ];    
  $options = [
    'sort' => array ('cw_product_code' => 1, 'download_Date' => 1 ),
    'group' => array ( '_id:' =>  '$cw_product_id', 'lastDownloadDate' => array('$last' => '$download_Date' )),
    'allowDiskUse' => true
];


--
Reply all
Reply to author
Forward
0 new messages