【发布时间】:2022-01-09 13:56:04
【问题描述】:
嘿,我一直在玩 mongodb geo api,它似乎非常有限,最值得注意的是不允许在它之前执行任何其他阶段的限制,我只遇到了可能的解决方案 $facet 但它限制了 @ 987654322@ 阶段也是如此,所以我没有选择,我需要在$geoNear 之前使用$match 阶段,我知道$geoNear 有它自己的查询,但geoNear 的coordinates 这是我当前的代码
{
$match: {/*query*/},
},
{
$geoNear: {
near: {
type: 'Point',
coordinates: '$geometry.coordinates' as unknown as [number, number],
},
distanceField: 'dist.calculated',
maxDistance: 1000000,
includeLocs: 'dist.location',
spherical: true,
},
},
我知道这不是一个错误,而是 mongodb 贡献者所说的一个功能,但我真的需要以某种方式解决这个问题并首先执行匹配
【问题讨论】:
标签: node.js mongodb mongoose aggregation-framework