gpt4 book ai didi

firebase - 如何从引用文档 (Firebase) 中的字段获取字符串数据

转载 作者:IT王子 更新时间:2023-10-29 06:50:17 26 4
gpt4 key购买 nike

在我的 Flutter 应用程序中,我想从包含对另一个集合的引用的字段中获取一些信息。我不知道如何从引用文档中的字段中获取信息。

下面是两个系列的两张图片。

第一张图片包含主要集合,其中字段(“geslacht”)指的是:“/gender/Girl”

Collection 1

第二张图片显示了引用的集合。

Collection 2

我目前已经写了以下文章(在这个 tutorial 之后)

class Record {
final String name;
var color;
final DocumentReference reference;
Record.fromMap(Map<String, dynamic> map, {this.reference})
: assert(map['name'] != null),
assert(map['geslacht'] != null),
name = map['name'],
color = map['geslacht'];
Record.fromSnapshot(DocumentSnapshot snapshot)
: this.fromMap(snapshot.data, reference: snapshot.reference);
@override
String toString() => "Record<$name:$votes>";
}

它完美地从名为“name”的字段中获取数据并返回名为“geslacht”的字段的 DocumentReference 实例

我很想获得此引用文档中的信息。所以总结“粉红色”的值(value)是我想要得到的。 (路径是 baby --> dana --> geslacht --> gender --> girl --> color --> pink )

在此先感谢您的帮助!

最佳答案

您必须使用该 DocumentReference get() 其他文档,就像您自己构建 DocumentReference 一样。 Cloud Firestore 不会自动为您遵循引用 - 您必须为此编写代码。

关于firebase - 如何从引用文档 (Firebase) 中的字段获取字符串数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57612761/

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