根据Cloud Firestore=>Data type文档,类型reference
在NoSQL世界中充当外键。但是当我在Fluter / Dart中查询它时。 Firestore中的数据库。
[采集]
注意:DocumentOne的数据类型都是reference
示例代码:
Firestore.instance.collection('CollectionWithReference').snapshots()
.listen((data) => data.documents.forEach((document) => print(document.data)));
产量
{FKOne:'DocumentReference'的实例,FKTwo:['DocumentReference'实例,'DocumentReference'实例','DocumentReference'实例'}
您的问题中的输出是可以预期的。
因为你的引用被解析为对象,所以print
只打印出Instance of 'DocumentReference'
。
Here you can take a look at the class DocumentReference
,其中包含有关您的参考的所有必要数据。
在下面的代码中,我将打印出每个引用的path
(每个DocumentReference
对象的getter):
Firestore.instance.collection('CollectionWithReference').snapshots().listen((data) {
data.documents.forEach((document) {
print(document.data['FKOne'].path);
document.data['FKTwo'].forEach((documentReference) => print(documentReference.path));
});
});