1

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);
3
  • Hey Christian. I'm having a really hard time following along with what you're trying to do. Can you add a println to the code that shows what the code delivers, and then show the values you'd expect (in the same format)? Commented May 17, 2019 at 1:12
  • My question is that how to manage comments HashMap? (add, update, remove), I have already been able to add, but I have not been able to modify and delete. Commented May 17, 2019 at 2:43
  • @Frank I want to do the same as this but using HashMap and not an Array : stackoverflow.com/questions/51202300/… Commented May 17, 2019 at 2:47

1 Answer 1

0

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/);

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.