mongodb - mongo runCommand 分页
仅有的幸福
仅有的幸福 2017-05-02 09:21:15
0
2
781

由于需要基于 mongo 空间索引 按照距离进行 数据查询,并且显示距离. 所以必须要用如下的方式进行查询.

db.runCommand({"geoNear":"coach2", "near":[113.525298,22.246466],"num":10, spherical:true,distanceMultiplier: 6378137,maxDistance:100/6378137, query:{account:"tcrct"}}

num是控制返回条数的.

但是现在我要要实现分页功能, 每一页20条, 查手册没有看到runCommand支持 skip类似的选项. 所以不知道如何实现分页了.

仅有的幸福
仅有的幸福

reply all(2)
曾经蜡笔没有小新

The author is obviously familiar with basic limit and skip. .

The mongodb mentioned by the poster does not currently support it, but you can do it through aggreation. The documentation is here. This supports limit and skip, which is also the current recommended approach.

漂亮男人

Thank you for the invitation. mongodbLike other databases, you can query the corresponding number of data for paging operations. The official documents also have corresponding instructions, such as mongodb.limit and mongodb.skip. Or you can refer to this Chinese description limit.skip. Hope it helps you

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!