firebase - 颤振:从火力基地获取文件
问题描述
我想带出模型集合的文档 id '1004'。我该怎么做?我只知道集合和文档 ID '1004'。
错误代码:
DocumentSnapshot _model = await carCollectionRef
.doc()
.collection(USER_CAR_COLLECTION)
.doc()
.collection(MODEL_COLLECTION)
.doc('1004')
.get();
解决方案
不是从Firestore
. 但这就是你得到它的方式。
foo() async {
Map<String, dynamic> myData;
await carCollectionRef
.get()
.then((snapshot) => snapshot.docs.forEach((element) {
if (element.exists) {
carCollectionRef
.doc(element.id)
.collection('USER_CAR_COLLECTION')
.get()
.then((snapshot2) => snapshot2.docs.forEach((element2) {
if (element2.exists) {
carCollectionRef
.doc(element.id)
.collection('USER_CAR_COLLECTION')
.doc(element2.id)
.collection('MODEL_COLLECTION')
.doc('1004')
.get()
.then((value) => {
if (value.exists) {myData = value.data()}
});
}
}));
}
}));
print(myData);
}
推荐阅读
- r - r:创建标准化变量作为新变量
- gdb - 显示 cdir 值
- sapui5 - valueState 从 sap.m.StepInput 中消失
- kubernetes - 服务外部 ip 待处理的 kubernetes
- android - 计算 TextView 大小
- node.js - 猫鼬填充不同的字段不给出正确的结果
- ios - sqlite3 选择总是返回“1”
- javascript - 无法使用 orderByChild 和 equalTo 从 firebase 查询
- javascript - 从输入类型文件中获取文件夹目录 - PHP
- android - 如何在 Java 代码中使用 Kotlin 协程实现 NIO Socket(客户端)?