【发布时间】:2020-12-14 02:21:08
【问题描述】:
我有 2 个收藏:
- 用户
- 通知
用户:
{
id:1,
name:ABC
},
{
id:2,
name:ABC2
},
{
id:3,
name:ABC3
}
通知:
{
id:1,
userId:1,
read:false,
info: 'Notification for user 1'
},{
id:2,
userId:2,
read:false,
info: 'Notification for user 2'
},{
id:3,
userId:3,
read:false,
info: 'Notification for user 3'
}
我想获取具有匹配(读取:false)、排序(createdAt 上的降序)、限制(5)的通知数据,并根据通知数据中的用户 ID 查找用户集合
查询应该返回:
[{
id:1,
userId:1,
read:false,
info: 'Notification for user 1'
username:ABC
},{
id:2,
userId:2,
read:false,
info: 'Notification for user 2'
username:ABC2
},{
id:3,
userId:3,
read:false,
info: 'Notification for user 3'
username:ABC3
}]
【问题讨论】: