0

I'm a newbie in firebase realtime database. i have got a data structures as below. How can i update a new property (TimeOut) at the same node without loss current properties?

enter image description here

has someone, he was supported me to update a new property with below method

firebase.database().ref('18-9/Working/TimeOut').set('5:20:30');
OR
firebase.database().ref('18-9/Working').update({ TimeOut: '5:20:30' });

, but it's still doesn't work, maybe my syntax was wrong.

I would appreciate it if someone could help me this issue

enter image description here

Dharmaraj
  • 47,845
  • 8
  • 52
  • 84
NamVu
  • 15
  • 2
  • What error do you get? Can you share a screenshot of the same? And also you are missing the `import "firebase/compat/database"`. Firestore adn RTDB are different databases. – Dharmaraj Sep 18 '22 at 05:45
  • thank u so much for helping me to slove an issue, just with edit from "firebase/compat/firestore" to "firebase/compat/database", the issue that i've got is done – NamVu Sep 18 '22 at 06:50
  • Glad to hear that. I posted the same an answer below so others will know it's resolved. – Dharmaraj Sep 18 '22 at 06:54

1 Answers1

1

Firebase Realtime Database and Cloud Firestore are different databases. In this case, you are using RTDB but importing the Firestore SDK. Adding the Realtime DB SDK should resolve the issue:

import "firebase/compat/database"
Dharmaraj
  • 47,845
  • 8
  • 52
  • 84