Jeet Mehta
Jeet Mehta

Reputation: 25

How to modify array values in firebase realtime database in react native

Here I want to modify value of ADDRESS Field. Here the value 1R6RsMMgQ.... represents the uid of each user. Here I am able to reach upto userDetails but I am unable to go to address key for modifying the value. Here the -MXcKsJV... value is the array key value which is generated at the time of pushing the value to database using the push() method.

I tried to update the value by writing this query

firebase.database().ref(`/user/${uid}/userDetails/`).update({address: 'change'})

By writing this query I would update the userDetails child but this would not been reflected in the array (i.e. -MXcKs... array)

Can anyone suggest me how to do this?

enter image description here

Upvotes: 0

Views: 333

Answers (1)

Lucas Pacheco
Lucas Pacheco

Reputation: 871

Your ref is to /user/1R6.../userDetails/ and not /user/1R6.../userDetails/-MXcK... You have to update your ref or fix your data structure.

Upvotes: 1

Related Questions