java - 如何在 Firestore 中插入对象数组?

标签 java firebase kotlin google-cloud-firestore

enter image description here我想在 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));

java

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

希望对大家有所帮助。

关于java - 如何在 Firestore 中插入对象数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52813901/

相关文章:

java - 无法使用 jdbc:sqlite::resource 将记录/数据保存到 SQLite 数据库:

java - firebase startAt() endAt() 方法

java - 如何从 java keystore 中选择正确的 SSL 证书,以便在相互 TLS 的情况下发送到相应的端点

kotlin - Kotlin-如果语句无法正常运行

android - 如何知道 ESP8266 是否在 Android 应用程序的 Firebase 中连接/断开连接?

java - 是否真的有一种方法可以保存访问过的网站的历史记录,以便当用户返回(重新打开应用程序)时,他可以在后按时获得访问过的网站列表

java - Spring MVC 3 网址初学者

java - 二维数组java中的Arrayindexoutofbounds

java - 为什么我不能直接在测试中 @Autowired 我的服务以及为什么我需要 @Autowired 存储库?

firebase - 如何检索列表中选定的项目以在详细页面 Flutter 中显示其详细信息