简体   繁体   中英

Accessing data in firebase database

So basically,I have a web application that uses firebase database. and I am having a hard time on how to access the encircled ones?

here is my code:

 function getDataFirebase() {
    return new Promise(function(resolve, reject){
        refReview.on("value", async function(snap){
            var data=snap.val();

            console.log("awdaw",data);

        })
    })
 }

在此处输入图片说明

Loop over snapshot returned from firebase to get values inside the object.

function getDataFirebase() {
    return new Promise(function(resolve, reject){
        refReview.on("value", async function(snap){
            let rootkey = snap.key
            console.log(rootkey)
            snap.forEach(snapshot => {
                let childKey = snapshot.key
                console.log(childKey)
                Object.keys(snapshot.val()).map(k => {
                  console.log(snapshot.val()[k])
                })
            })
        })
    })
}

This case falls when we don't know the value of generated timestamps from firebase as child nodes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM