当前位置:Gxlcms > 数据库问题 > mongodb分页查询,排序

mongodb分页查询,排序

时间:2021-07-01 10:21:17 帮助过:28人阅读

mongodb代码

根据时间倒序,查看10条
db.表名.find({"_id":"xxx"}).sort({"inserted":-1}).limit(10).skip(1)

  

相对的php代码

  $postArr = $this->mongo->executeQuery(
            表名,
            [
                ‘_id‘ => new ObjectId(字符串id)
            ],
            [
                ‘sort‘ => [
                    ‘inserted‘ => -1
                ],
                ‘limit‘ => 10,
                ‘skip‘ => 1,
                ‘projection‘ => array(
                    ‘_id‘ => 1
                )
            ]
        );


  

mongodb分页查询,排序

标签:.so   object   class   his   log   exec   logs   字符串   分页查询   

人气教程排行