search

Home  >  Q&A  >  body text

mongodb - mongo runCommand 分页

由于需要基于 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类似的选项. 所以不知道如何实现分页了.

仅有的幸福仅有的幸福2788 days ago816

reply all(2)I'll reply

  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-05-02 09:23:15

    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.

    reply
    0
  • 漂亮男人

    漂亮男人2017-05-02 09:23:15

    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

    reply
    0
  • Cancelreply