【发布时间】:2016-05-21 19:51:05
【问题描述】:
我正在使用 laravel 5.1 并使用 jessenger mongodb 包。 我正在使用原始查询来获取数据,但我很困惑如何使用日期,因为它目前正在返回空结果。
$resultSet = DB::connection('mongodb')->collection('wc_mycollection')->raw(function ($collection){
return $collection->aggregate([
[
'$match'=>[
'created_at'=>[
'$gte' => Previous day midnight,
'$lt' => Current Time
]
]
],
[
'$group' => [
'_id' => '$some_id',
]
]
]);
});
我该怎么办?
【问题讨论】:
-
分配日期参数后,打印查询并查看日期参数是否设置正确,如果是,则尝试将该时间戳转换为基于 mongo 的时间格式。看这里:docs.mongodb.org/v3.0/core/shell-types/#mongo-shell-date-type
标签: php mongodb laravel jenssegers-mongodb