云函数代码正确,数据库里也有author_likes_id的值,可就是查询不出来?
来源:9-5 同步关注作者页面数据

奇点博乐
2021-05-10
云函数代码正确,数据库里也有author_likes_id的值,可就是查询不出来?
'use strict';
const db = uniCloud.database()
const $ = db.command.aggregate
exports.main = async (event, context) => {
const {
user_id
} = event
let userInfo = await db.collection("user").doc(user_id).get()
userInfo = userInfo.data[0]
let lists = await db.collection("user")
.aggregate()
.addFields({
is_like: $.in(['$id',userInfo.author_likes_ids])
})
.match({
is_like:true
})
.end()
//返回数据给客户端
return {
code:200,
msg:"获取成功",
data:lists.data
}
};
返回结果:
[imooc-news] 15:27:29.886 [云端运行:阿里云:imooc-news]运行状态:成功
[imooc-news] 15:27:29.886 [云端运行:阿里云:imooc-news]返回结果:{“code”:200,“msg”:“获取成功”,“data”:[]}
[imooc-news] 15:27:29.886 [云端运行:阿里云:imooc-news]运行日志:
[imooc-news] 15:27:29.886 [云端运行:阿里云:imooc-news]运行报告:计费时间:200ms 运行时间:145ms 运行内存:35.9MB
写回答
1回答
-
奇点博乐
提问者
2021-05-10
好吧,找到问题了,原来是在详情页中点击关注时,传入的id并不是author的id,是article的id,所以肯定查询是空,细节啊......
00
相似问题