[英]How can i manually add document-fields into local QueryDocumentSnapshot List
i have the following list我有以下列表
List <QueryDocumentSnapshot> globalVideosUrls = [] ;
for example if we use the following例如,如果我们使用以下
FirebaseFirestore.instance.collection('users')
.limit(1).get().then((value){
globalVideosUrls.add(value)
});
it will add as expected它会按预期添加
but what if i want to manually add the following data into globalVideosUrls
但是如果我想手动将以下数据添加到
globalVideosUrls
document id文档编号
00dcb026-3163-4ca0-859e
fields字段
'videoType':'peace'
'url':'url'
.
globalVideosUrls
.add(????) globalVideosUrls
(???)
You have to replace the type "QueryDocumentSnapshot" with QuerySnapshot and then you will get multiple docs and with there data also try this If any questions then ask.您必须将类型“QueryDocumentSnapshot”替换为 QuerySnapshot,然后您将获得多个文档,并且那里的数据也试试这个如果有任何问题,请询问。 thanks.
谢谢。
List<QuerySnapshot> globalVideosUrls = [];
List<String> videoUrlList = [];
await FirebaseFirestore.instance
.collection('users')
.get()
.then((value) {
globalVideosUrls.add(value);
});
globalVideosUrls.forEach((element) {
element.docs.forEach((docELe) {
print("data:- ${docELe.data()}");
Map map = docELe.data() as Map;
videoUrlList.add(map['url']);
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.