java - 如何在 Firestore 中插入对象数组?
问题描述
我想在 Firestore 中插入一组对象?我可以从 Firestore 控制台添加,但是从 Java 中添加它不起作用?在这里,我附上了我的控制台快照,代码是:
val map = HashMap<String, Any>()
map["one"] = request.records
dayFormDoc.set(map)
这里 request.records 是一个数组。
解决方案
尝试这个,
安卓
Map<String, Object> docData = new HashMap<>();
docData.put("listExample", Arrays.asList(1, 2, 3));
爪哇
ArrayList<Object> arrayExample = new ArrayList<>();
Collections.addAll(arrayExample, 5L, true, "hello");
docData.put("arrayExample", arrayExample);
更多信息https://firebase.google.com/docs/firestore/manage-data/add-data
希望能帮上忙。
推荐阅读
- python - 有没有办法将mariadb与python2.7连接起来
- ios - 滚出屏幕时如何访问 CollectionView 标题(即不可见)
- javascript - JQuery - 暂停动画/添加下一个按钮
- android - 垂直显示效果,如 RecycleView 单元格中的折叠视图
- c++ - 内联调用 always_inline 失败,Qt 中的目标特定选项不匹配
- android - 从 Android 中的 AWSAppSyncClient 删除/清除缓存策略
- keras - 从高层架构实现cnn时,如何确定每一层的步幅和填充类型?
- html - Angular Material:当触发器位于不同组件中时如何切换sidenav
- c++ - GCC:在调试版本中优化的静态数据成员
- xamarin - Xamarin HybridWebView 未在 iOS 设备中加载 url