我想在 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/