firebase - 将映射或数组的数据类型上传到 Firestore 数据库以匹配 Firestore 映射和数组类型

标签 firebase dart flutter google-cloud-firestore firebase-storage

我有一张 Map<String, String> 类型的 map 我正在尝试将其上传到 Firestore 以匹配可用作字段的 map 数据类型。见下图。

我尝试使用 map 类的 toString 方法并将其分配给一个字段,但它显示为长字符串而不是 map ,请参阅下面的代码片段

Firestore.instance.collection('/mycollection').add({
  'mapData' : myMap.toString(), // myMap.toString() = {data: test, data2: name}
}).then((onValue) {
  // do something
}).catchError((e) {
  print(e);
});

上面的代码片段上传 myMap 的字符串值作为字符串并将其分配给 mapdata 。它不会将 map 格式的数据发送到Firestore

关于如何发送 Map<string, string> 类型的任何想法到 Firestore 映射 map 的类型Firestore 提供吗?也来自List到 Firestore array

最佳答案

我认为这会起作用

Firestore.instance.collection('/mycollection').add({
  'mapData' : myMap,
}).then((onValue) {
  // do something
}).catchError((e) {
  print(e);
});

关于firebase - 将映射或数组的数据类型上传到 Firestore 数据库以匹配 Firestore 映射和数组类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54001190/

相关文章:

angular - 类型 'FileUpload[][]' 不可分配给类型 'AngularFireList<FileUpload[]>'

swift - 无法将任何对象转换为字符串

dart - @observable和@published有什么区别

android - notifyListener 的奇怪行为

gridview - 如何在 Flutter 中将 gridView 项目居中?

android - 如何正确地将数据从Android发送到Flutter?

ios - 无法在 Swift 中使用 Xcode 9 消除 Firebase Analytics 线程警告

dart - 在 StreamBuilder 中加载数据时如何显示进度指示器?

modalBottomSheet 内的 Flutter ExpansionPanelList 不更新状态

javascript - 在快照之后操作 Firebase 元素