geoNear无法使用count()

发布于 7 年前作者 gangsong12386 次浏览最后编辑 7 年前来自 ask
  • 当前 Bug 的表现(可附上截图)

  • 预期表现

  • 复现路径

  • 提供一个最简复现 Demo

db.collection('user_address')
 
.where({
 
location: _.geoNear({
 
geometry: user_location[0].location,
 
minDistance: 0,
 
maxDistance: 5000
 
})
 
})
 
.count({
 
success: function (res) {
 
console.debug("db.collection('user_address')", res)
 
},
 
fail:err=>{
 
console.debug("db.collection('user_address')", err)
 
}
 
})

如上代码,运行后返回错误:

db.collection(‘user_address’) Error: errCode: -502001 database request fail | errMsg: [FailedOperation.Query] (BadValue) $geoNear, $near, and $nearSphere are not allowed in this context

求解使用geoNear查询附近的点如何过去查询结果的总条数,如果不支持count,应该如何获得总的记录条数?

1 回复
hshi
hshi1 楼5 年前

我也遇到这个问题了,既然get一次限制返回20条,count能不能打开啊!