查找给出错误,因为尽管查询正确,但缺少 from
对于使用 mongoose 的 mongo 中的 this 模型,查询如下:收到错误 MongoServerError: Missing ' from' 选项到 $lookup 阶段规范: { localField: "vendor",foreignField: "_id", as: "vendors" }
const items = await VendorItem.aggregate([
{$lookup : { from: Vendor, localField: 'vendor', foreignField: "_id", as: "vendors"}},
{$group: {categories: '$category'}}
]);
For this Model in mongo using mongoose, and query as following : gets error MongoServerError: missing 'from' option to $lookup stage specification: { localField: "vendor", foreignField: "_id", as: "vendors" }
const items = await VendorItem.aggregate([
{$lookup : { from: Vendor, localField: 'vendor', foreignField: "_id", as: "vendors"}},
{$group: {categories: '$category'}}
]);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论