Arshdeep Singh
Arshdeep Singh

Reputation: 316

How to update a field existing inside map of document in Firestore

I've kinda figured out that we can update just one field inside the map of the document

enter image description here

Like here I can add one more field to courses key, like

Map<String, Object> nested = new HashMap(){};
nested.add("sample field inside courses");

and passing it to another like

Map<String, Object> courses = new HashMap(){};
courses.add();

Q. How can I update the value of abbreviation_color which is the last field in the above image?

Upvotes: 1

Views: 723

Answers (1)

Cyb3rKo
Cyb3rKo

Reputation: 464

Here's my test document:

1


If I now want to update "Test2" I simply call...

yourDocumentReference.update("a.b2.c2", "New Value")

which results in this:


2


Edit: It does not care if it contains spaces or not, if "b2" would be "b 2" you could easily call

yourDocumentReference.update("a.b 2.c2", "New Value")

I hope I could help somebody!

Upvotes: 3

Related Questions