According to Cloud Firestore=>Data type Documentation, type reference act as foreign key in NoSQL world. but when I query it in Fluter/Dart.
Database in Firestore.
[Collection]
Note: DocumentOne's data type are all reference
Example Code:
Firestore.instance.collection('CollectionWithReference').snapshots()
.listen((data) => data.documents.forEach((document) => print(document.data)));
Output
{FKOne: Instance of 'DocumentReference', FKTwo: [Instance of 'DocumentReference', Instance of 'DocumentReference', Instance of 'DocumentReference']}
The output in your question is to be expected.
Because your references are parsed as objects, print will only print out Instance of 'DocumentReference'.
Here you can take a look at the class DocumentReference, which contains all the necessary data about your reference.
In the following code I will print out the path (which is a getter of every DocumentReference object) of each of your references:
Firestore.instance.collection('CollectionWithReference').snapshots().listen((data) {
data.documents.forEach((document) {
print(document.data['FKOne'].path);
document.data['FKTwo'].forEach((documentReference) => print(documentReference.path));
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With