简体   繁体   English

添加到特定文档的 map 字段 (Flutter Firestore)

[英]Adding onto a map field of a specific document (Flutter Firestore)

I am using flutter firestore and want to only add users(using the userInfo map) (and not add any other fields) to a specific document in my PrayerRooms Collection.I am unsure of how to do this and whether this is possible The database I want to add into我正在使用flutter firestore 并且只想将用户(使用 userInfo 映射)(而不是添加任何其他字段)添加到我的 PrayerRooms 集合中的特定文档。我不确定如何执行此操作以及这是否可能数据库我想加入

If you have other fields and you just want to add data to the userInfo map while keep the other fields, then you can use updateData() :如果您有其他字段,并且只想向userInfo map 添加数据,同时保留其他字段,则可以使用updateData()

 Firestore.instance.collection("PrayersRoom").document(userId).updateData({
                     "userInfo.userId" : userId,
                     "userInfo.userCount" : 2
                   });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 更新 Firestore 集合中最后一个文档中的一个字段 Flutter - Update a field in the last document in Firestore collection Flutter 从 flutter firestore 中的子集合中获取特定文档 - fetching a specific document from a subcollection in flutter firestore Flutter 对文档数组字段的firestore查询 - Flutter firestore query on document array field Firebase Firestore - 如何从特定文档中检索数组字段并将这些数组值用于 map 文档 - Firebase Firestore - how to retrieve an array field from a specific document and use those array values to map documents 如何更新 Firestore 文档中特定字段的值? - How to update value of a specific field in Firestore document? Firestore - 添加一个新字段将其设置为“地图” - Firestore - Adding a new field sets it as "map" Query Document 在 Flutter 的 Firestore 中获取特定 collections 的快照 - Query Document to get snapshots from specific collections in Firestore in Flutter 在嵌套的 map 中查询带有时间戳字段的 firestore 文档 - Query a firestore document with a timestamp field inside a nested map Flutter:如何获取 Firestore 文档中字段(列表)的长度? - Flutter : How to get the length of field (list) in Firestore document? 如何使用嵌套的 map 字段为带有 flutter 的云 Firestore 创建用户 model? - How to create user model with nested map field for cloud firestore with flutter?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM