a***@qq.com
a***@qq.com
  • 发布:2024-04-23 11:09
  • 更新:2024-04-23 11:09
  • 阅读:62

聚合查询 lookup let 联表查询 数组报错Query failed with error code 17276 and error message

分类:uniCloud

const collection = dbA.collection("uni-cms-articles").aggregate().project({
_id: true,
plat_form_popularity: true,
fb_publish_date: true,
user_id: true,
map_poi: true,
category_id: true,
title: true,
excerpt: true,
thumbnail: true
})
.lookup({
from: 'opendb-poi', // 关联集合名称
let: {
map_poi: '$map_poi', // 定义关联字段
},
pipeline: $.pipeline()
.match(cmd.expr(
$.and(
[
$.in(['$$map_poi', '$_id']) //, // 关联条件
// $.eq(['$visible', true]),
]
)
))
.project({
_id: 1,
thumbnail: 1, //封面
})
.done(), // 结束关联管道
as: 'poi', // 关联结果存储字段
})
.lookup({
from: 'uni-id-users', // 关联集合名称
let: {
user_id: '$user_id', // 定义关联字段
},
pipeline: $.pipeline()
.match(cmd.expr($.and(
[
$.eq(['$_id', '$$user_id']) // 关联条件
]
)))
.project({
_id: 1,
nickname: 1,
avatar: 1,
user_resume: 1
})
.done(), // 结束关联管道
as: 'user', // 关联结果存储字段
})
.end();

uni-cms-articles表的map_poi 字段类型是数组 关联了opendb-poi 字段的id 查询出来报Query failed with error code 17276 and error message 'Use of undefined variable: map_poi' on server 错误

2024-04-23 11:09 负责人:DCloud_uniCloud_CRL 分享
已邀请:

要回复问题请先登录注册