gpt4 book ai didi

javascript - Firebase 填充嵌套值

转载 作者:行者123 更新时间:2023-12-03 02:44:08 26 4
gpt4 key购买 nike

有办法吸引学生吗?

"cohortStudents": {
"cohort-id-4": {
"cohortId": "cohort-id-4",
"instructorId": "CZVLBcZ7lQe2OUcHdDLjW4OVFaB2",
"students": {
"student-id-1": true,
"student-id-2": true,
"student-id-3": true
}
}
}

所以基本上我可以通过
cohortStudents获取数据https://[项目名称].firebaseio.com/cohortStudents.json?orderBy="cohortId"&equalTo="cohort-id-4"

我会得到对象,但students:{}仍将有student-id-1

有没有办法让数据看起来像 students: { Student-id-1: { name: '', email: '' } }

希望得到您的帮助

最佳答案

Firebase 数据库查询仅从单个位置读取子节点。不支持服务器端连接。

要获取从学生引用的用户,您必须执行客户端连接:单独加载每个用户。

我强烈建议使用 Firebase SDK 来执行此操作,因为它针对此类用例进行了优化。请参阅my answer to this question for more .

关于javascript - Firebase 填充嵌套值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48175120/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com