简体   繁体   中英

How to Add Map<String, Object> elements in firebase firestore android using Hashmap? A Store Database

With the last improvement in matrices, you can add, update and delete an element but only in matrix.

But for:

Map<String, Object> comentarios = new HashMap<>();

I probe it and it transforms me a Map to array does not matiene the same type. Someone know how I should do it?

My code is:

final Map<String, Object> nuevoComentario = new HashMap<>();
nuevoComentario.put("comentario", FieldValue.arrayUnion("id5", "Msj add"));
db.collection("Hospedaje").document(documentGetID)
                        .update(nuevoComentario);

From what I understand FieldValue.arrayUnion and FieldValue.arrayRemove are just for array fields, which HashMap isn't really. Try using db.collection("Hospedaje").document(documentGetID).update("myHashMapField", "key" to /value/);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM