Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

392
Views
read value from firebase database using Javascript(parent,child + parent,child,child)

i have a firebase database where as i want to read parent=>child and parent==>child==>child as shown in the attached screenshot

js

Code that reads parent==>child (finance,userid,email...) successfuly

try
            {
                const dbref = ref(db);
                get(child(dbref,"finance")).then((snapshot)=>
                {
                var client=[];
                snapshot.forEach(childSnapshot =>
                {
                    const data = childSnapshot.val();
                    client.push(data);

                });
                AddAllItemsToTable(client);
            });

How can i read finance==>userid==>id==>value1,value2

neededReadValues

 "finance": {
    "lvAN928K9qXJ5RGiRBUrb6seByM2": {
      "-N6XXgy0COp30w52pxzZ": {
        "link": "https://firebasestorage.googleapis.com/v0/b/myhouse-4ba96.appspot.com/o/Documentdocument%3A76094?alt=media&token=5fc3eda7-00ed-4a47-a6e0-1f89dfdabca9"
      },
      "-N6XXh2rkW0jT7MNpO2-": {
        "link": "https://firebasestorage.googleapis.com/v0/b/myhouse-4ba96.appspot.com/o/Documentdocument%3A76093?alt=media&token=7e2e59ea-7821-4a8b-8b93-9fe17b4b1118"
      },
      "email": "app@email.com",
      "houseContractor": "General construction ",
      "houseCost": "2400000",
      "income": "1200000",
      "institution": "Commercial Banks",
      "nic": "123456789",
      "permit": "Yes"
    }
  }

I have tried

try
                    {
                        const dbref = ref(db);
                        get(child(dbref,"finance")).then((snapshot)=>
                        {
                        var client=[];
                        snapshot.forEach(childSnapshot =>{
                            let item1=childSnapshot.val();
                            client.push(item1);
                            childSnapshot.forEach((grandchildSnapshot) =>{  
                                let item=grandchildSnapshot.val()
                                item.key=grandchildSnapshot.key
                                client.push(item)
                            });
                            
                        });
                        AddAllItemsToTable(client);
                    });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

In your current structure all you can do to get to the links is to loop over all child nodes again:

const dbref = ref(db);
get(child(dbref,"finance")).then((snapshot)=>{
  var client=[];
  snapshot.forEach(childSnapshot => {
    childSnapshot.forEach((grandchildSnapshot) => {
      if (grandchildSnapshot.hasChild("link")) {
        console.log(grandchildSnapshot.child("link").val());
      })
    })
  })
})
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!