javascript - $geoNear 仅作为管道中的第一阶段有效
问题描述
在使用服务器端$geoNear is only valid as the first stage in a pipeline.
进行聚合时出现以下错误。nodejs
聚合对象:
[ { '$geoNear':
{ near: [Object], distanceField: 'distance', spherical: true } },
{ '$lookup':
{ from: 'reviews',
localField: '_id',
foreignField: 'restaurant',
as: 'reviews' } },
{ '$project':
{ logo: '$$ROOT.logo',
name: '$$ROOT.name',
cuisine: '$$ROOT.cuisine',
rate: [Object],
reservation: '$$ROOT.reservation',
closeAt: '$$ROOT.closeAt',
openAt: '$$ROOT.openAt',
recommendationsLength: [Object],
isLive: '$$ROOT.isLive',
avgCost: '$$ROOT.avgCost',
creationDate: '$$ROOT.creationDate',
distance: '$$ROOT.distance' } },
{ '$sort': { distance: 1 } } ]
知道为什么我会收到上述错误吗?
解决方案
检查并查看是否有任何预中间件函数执行聚合。如果是这样,那么这很可能是错误的根源。
推荐阅读
- azure - Azure DevOps 项目 - Service Fabric 部署 - 示例失败
- android-studio - Android Stuido,更改应用程序名称后无法在我的设备上运行该应用程序
- node.js - 错误:错误:2006D080:BIO 例程:BIO_new_file:没有这样的文件
- typescript - 打字稿:如何在映射列表时进行类型检查
- xml - 使用 Kotlin 在 Spring Boot 中嵌套 xml 响应
- reactjs - 酶反应打字稿测试不模拟点击
- oauth-2.0 - Passport.js 对 Gmail API 进行身份验证导致 GooglePlusAPIError
- telegram - 如何使用 Telegram 机器人获取频道更新
- jenkins - 在阶段詹金斯管道之间传递变量
- vue.js - 将 store 加载到 vue js 中