mongodb分頁查詢,排序


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
                )
            ]
        );


  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM