exports.main = async (event, context) => {
//event为客户端上传的参数
console.log('event : ', event)
//客户端传过来的分类id
const cateid = event.cateid
const db = uniCloud.database()
const dbCmd = db.command
let res = await db.collection('opendb-news-articles').aggregate()
.lookup({
from: 'opendb-news-categories',
localField: 'category_id',
foreignField: '_id',
as: 'List',
})
.match({
category_id:dbCmd.eq(cateid)
})
.end()
//返回数据给客户端
return res
};
w我想查询某分类下的文章,为啥返回为空啊,不加.match会返回全部文章,加了之后返回为空数组。是我哪里写错了吗?
category_id:dbCmd.eq(cateid)
id写死返回也是为空