【发布时间】:2018-03-20 06:45:57
【问题描述】:
好吧,根据文档,这个答案https://stackoverflow.com/a/46639620/2873357,集合和文档应该交替。
我需要以这种方式构造我的数据:
"app" :{
"users" :{
"$uid" :{
"notifications":{
"auto-gen-id" :{
"notif-object":{
"type":"",
"subType" : ""
}
}
}
}
}
}
所以,据我了解,这是,
: "app (collections)/
users (document)/
$uid (collections)/
notifications (document)/
auto-gen-id (collections)/
"notif-object" (document)/
type (field),
subType (field)
我似乎无法在 Firebase 控制台中实现这种功能。
【问题讨论】:
-
嗨尝试扁平化firebase结构,为通知创建单独的节点,在用户ID下存储用户的通知...如果您使用嵌套一个,则需要时间来获取数据
-
@Shanmugam 请忽略时间,我仍然需要按照我的要求这样做。
-
您遇到什么问题,您的要求是什么
-
我的要求是以我在问题中指定的格式获取 json。
-
Collections 和 Documents 是不同的东西,您不能互换使用它们。将原始 JSON 映射到 Cloud Firestore 而不对其进行调整以匹配 Cloud Firestore 的数据模型可能效果不佳。您要么坚持使用实时数据库(其数据模型更灵活),要么调整您的数据模型以更好地与 Cloud Firestore 配合使用。
标签: java android firebase google-cloud-firestore