MongoDB不返回结果或忽略lte/gte
我将聚合与以下代码一起使用:MongoDB不返回结果或忽略lte/gte,mongodb,laravel-5,Mongodb,Laravel 5,我将聚合与以下代码一起使用: $result = \DB::connection('mongodb')->collection('urls')->raw(function($collection) use ($alias) { $from = new \MongoDate( strtotime('2015-01-01 00:00:00') ); $to = new \MongoDate( strtotime('2015-01-3
$result = \DB::connection('mongodb')->collection('urls')->raw(function($collection) use ($alias)
{
$from = new \MongoDate( strtotime('2015-01-01 00:00:00') );
$to = new \MongoDate( strtotime('2015-01-31 00:00:00') );
return $collection->aggregate([
['$match' =>
[
'alias' => $alias,
'clicks.created_at' => [
'$lte' => $to,
'$gte' => $from
]
]
],
['$unwind' => '$clicks'],
['$project' => [
'clicks' => 1
]
],
['$group' => [
'_id' => [ 'day' => [ '$dateToString' => [ 'format' => '%Y-%m-%d', 'date' => '$clicks.created_at' ] ] ],
'count' => [ '$sum' => 1 ]
]
],
]);
});
return $result;
虽然我在这个时间段内有记录,但没有返回任何记录。知道为什么吗