0

Here i'm using firestore query to update, insert data. How to upadate dictionary of array value to firebase database.

here is my firestore data structure: enter image description here

Right now able to get data of slot1 -> 0th position value in a model class. how can i update value of slot1 0th position of isbooked boolean value alone, without affecting remaining values and other slot.

2 Answers 2

2

You can't without reading the entire document, modifying the array data in memory, then updating the entire array field back out do the document. The smallest unit of change in a Firestore array field is an entire field. You can't make smaller changes to individual elements of a field, except those defined by arrayUnion and arrayRemove (which are not compatible with what you're trying to do here).

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

3 Comments

do you mean the whole slotName dictionary or slot1 arrray? can you help me out of this?
The array. I already said what you have to do - read the document, make changes in memory, write the field back out.
@Mac_Play still i didnt find answer for this. So i asked backend developer to update it
1

You can do that by getting the exact id of your structure ..

Database.database().reference().child("SlotName").child(yourAry.key).child(yourAry.key).child("isbooked").setValue(true/false)

Manage your database structure accordingly, its just an example and as user Doug suggested have a look on docs too ..

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.