简体   繁体   English

如何在反应原生中修改 firebase 实时数据库中的数组值

[英]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.

相关问题 如何在 React Native 中将 Firebase 实时数据库数据值加一? - How to increment Firebase Realtime database data values by one in React Native? 如何使用Firebase Realtime数据库和React Native上传图像/文件? - How to upload an image / file using Firebase Realtime database and React Native? 将 Firebase 实时数据库与 React Native 应用程序集成 - Integrating Firebase Realtime Database with React Native App 使用本机反应更新 firebase 实时数据库中的 2 个子项 - Update 2 children in firebase realtime database with react native 如何跳过值实时数据库firebase - How to skip values realtime database firebase 使用 react native 在实时数据库 firebase 中检索孩子的孩子 - Retrieve children of child in realtime database firebase with react native 无法从 React Native 中的 Firebase 实时数据库读取数据 - Unable to read data from Firebase Realtime Database in React Native 如何从 Firebase 实时数据库中获取数据,这些数据是随机密钥的子项 - 使用本机反应? - How do I fetch data from firebase realtime database which are children to a random key - using react native? 从 firebase 实时数据库中获取数据时如何通过 function 返回数据 - how to return data through function when fetching data from firebase realtime-database in react native 如何从 firebase 实时数据库中呈现 ScrollView React Native (expo cli) 中的数据? - How to render data in ScrollView React Native (expo cli) from firebase realtime database?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM