【发布时间】:2019-03-14 17:31:30
【问题描述】:
假设 Firebase 数据存储 Db 是...
Collection("Collection1").
Document("documentX").
Collection("CollectionA").
field("FieldB")
在 Golang 中,使用 firebase admin SDK...在 GoLang 中获取 FieldB 值的代码是什么? 这是我尝试过的......
// dsnapp, err := client.Collection("Collection1/documentX").Get(ctx)
// dsnapp, err := client.Collection("Collection1").Document("documentX").Collection["CollectionA"].Get(ctx)
dsnapp2, err := client.Collection("Collection1").Doc("documentX").Get(ctx)
m = dsnapp2.Data()
fmt.Printf("222 Document data: %#v\n", m["CollectionA"]["FieldB")
还有其他各种技术……有什么建议吗?
【问题讨论】:
-
字段不能直接存在于集合中。集合或子集合只能包含文档,文档包含字段。
-
听起来像是道格的回答。
-
如何检索整个文档,解组它然后从结构中获取值?
标签: firebase go google-cloud-firestore google-admin-sdk