【发布时间】:2020-10-17 04:24:14
【问题描述】:
您好,我有一个如下所示的 mongoose 架构,
const followingFollowersSchema = mongoose.Schema({
follower: {
type: mongoose.Schema.ObjectId,
ref: 'User'
},
following: {
type: mongoose.Schema.ObjectId,
ref: 'User'
},
});
我在调用时创建了一个路由,它过滤当前登录用户正在关注的所有用户并显示以下输出,
{
"status": "success",
"results": 1,
"data": {
"following": [
{
"_id": "5ef4cd0205070d87156e19da",
"following": {
"_id": "5eeb92d69fceed6d91ad5743",
"name": "X Y"
}
}
]
}
}
但我想显示这样的输出,
{
"status": "success",
"results": 1,
"data": {
"following": [
{
"_id": "5eeb92d69fceed6d91ad5743",
"name": "X Y"
}
]
}
}
我怎样才能做到这一点?任何帮助将不胜感激。
【问题讨论】:
标签: node.js json mongodb mongoose