$mongo = Db::connect('database.mongodb');
$query = $query = [
'aggregate'=>'表名',
'pipeline'=>[
[
'$match'=>['条件查询的字段'=>条件], //条件
'month'=>['$lte'=>intval(date('m',time()))],
],
[
'$group'=>['_id'=>'$month'] //分组
],
[
'$sort'=>['_id'=>1] //排序 1升序 -1倒叙
] ,
[
'$count'=>['别名']
],
//这是条件或查询 $or 并且 $and
[
'$match'=>[
'$or'=>[
[
'From_Account'=>'','To_Account'=>''
],
[
'To_Account'=>'','From_Account'=>''
]
],
]
],
],
'cursor'=>new \stdClass(),
];
$data = $this->mongodb->cmd($query);
//仅限参考
//分页
$page = [
[
'$limit' => $page * $limit
],
[
'$skip' => ($page - 1) * $limit
],
];