将MongoDB查询转换为jenssegers / laravel-mongodb

时间:2018-03-19 15:03:26

标签: php mongodb laravel jenssegers-mongodb

你会如何写这样的查询

db.collection.find({$expr: {$lte: [{ $mod: [ '$created_at', 3600 ] }, 59]}});

使用jenssegers / laravel-mongodb扩展

1 个答案:

答案 0 :(得分:1)

使用原始表达式following the documentation

YourModel::whereRaw([
            '$expr' => [
                '$lte' => [
                    [
                        '$mod' => [
                            '$created_at', 3600
                        ],
                        59
                    ]
                 ]
            ]
        ])->get();