Closed Crazyskink closed 2 years ago
Hi @Crazyskink, the syntax for realtime is different from firestore. You can check the example for realtime database here.
https://firebase.google.com/docs/database/web/read-and-write#read_data_once_with_get
const dbRef = firebase.database().ref();
dbRef.child("users").child(userId).get().then((snapshot) => {
if (snapshot.exists()) {
console.log(snapshot.val());
} else {
console.log("No data available");
}
}).catch((error) => {
console.error(error);
});
Describe the bug code from https://firebase-wordpress-docs.readthedocs.io/en/latest/developer/retrieve-data.html and is work but I just want to know how can I retrived from realtime database.
I had change const db = firebase.firestore(); to const db = firebase.realtime(); and it's not work.
If my data base had struction like this collectionName/documentName/ID/password
Did I just use db.collection(collectionName).doc(documentName).doc(ID).doc(password) to retrive password?
Do you have sample code of customize upload data realtime database?