[英]How to modify array values in firebase realtime database in react native
Here I want to modify value of ADDRESS Field.这里我想修改 ADDRESS 字段的值。 Here the value 1R6RsMMgQ.... represents the uid of each user.这里的值 1R6RsMMgQ.... 代表每个用户的 uid。 Here I am able to reach upto userDetails but I am unable to go to address key for modifying the value.在这里我可以达到 userDetails 但我无法 go 来修改值的地址键。 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.这里的 -MXcKsJV... 值是在使用 push() 方法将值推送到数据库时生成的数组键值。
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 (ie -MXcKs... array)通过编写此查询,我将更新 userDetails 子项,但这不会反映在数组中(即 -MXcKs...数组)
Can anyone suggest me how to do this?谁能建议我如何做到这一点?
Your ref is to /user/1R6.../userDetails/ and not /user/1R6.../userDetails/-MXcK... You have to update your ref or fix your data structure.您的参考是 /user/1R6.../userDetails/ 而不是 /user/1R6.../userDetails/-MXcK... 您必须更新您的参考或修复您的数据结构。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.