javascript - RN Javascript - 修改对象列表中的条目
问题描述
有一个逻辑问题让我整天发疯;希望你们能帮忙!
因此,我使用 google maps api 从日历中返回事件列表,然后过滤这些事件以查找用户所属的特定事件(电子邮件在与会者中);现在我正在尝试提取活动参与者,检查其他用户的电子邮件,对其运行查询以返回他们的姓名和图片,然后将该对象及其姓名和图片附加到原始活动中,然后再次返回整个列表与更新的条目。
这是我从服务器获得的事件:
{ ...
id: 'ID',
status: 'confirmed',
description: 'Keyword'
start: [Object],
end: [Object],
attendees: [Array],
reminders: [Object]
...
}
我提取不是用户的与会者的电子邮件,并在我的本地数据库上运行查询以获取他们的姓名和照片,然后我想添加,以便事件显示为这样;
{ ...
id: 'ID',
status: 'confirmed',
description: 'Keyword'
start: [Object],
end: [Object],
attendees: [Array],
reminders: [Object]
...
opponent: {name: 'Name', picture: 'Picture_URL'}
}
这是我到目前为止所拥有的:
const events = results.data.items.filter(event => {
return (
event.description &&
event.description.includes('Keyword') &&
event.attendees.some(attendee => {
return attendee.email === currentUser.email;
})
);
});
Events come back fine from here, filtered with the events that include the user in attendees. I can't seem to get the next bit to work where I would modify the {event} object and add the {opponent} to it.
const opponent = events.map(event => {
return event.attendees.filter(async attendee => {
if (attendee.email !== currentUser.email) {
return await prisma.query
.user({ where: { email: attendee.email } })
.then(user => {
return {
name: user.name,
picture: user.picture,
};
})
.catch(err => {
return;
});
}
});
});
PS:prisma.query.user 返回一个 Promise。
非常感谢任何关于我所缺少的方向或帮助!
多谢你们!:)
解决方案
推荐阅读
- python - 在 Python 中创建 Azure 密钥保管库
- swift - 如何在 swift ui 中调整形状以适应文本视图的长度和宽度
- javascript - 根据第 n 个深度嵌套对象中的属性过滤对象
- python-3.x - 为什么我在使用 Reddit API 时收到 429 错误?
- python - 如何从 multiIndex 数据框中选择特定列?
- javascript - 检查来自 json 对象的所有值以呈现视图
- python-3.x - Sobel滤波器实现
- html - 如何使用 html 在 x 轴上的表格中重复图像?
- c++ - std::vector 和 std::array 之间的区别
- .net - Ms Graph 读取消息给出 ErrorAccesDenied