@Ayesha (Ayan Shah) posted a new topic, subject "Retrieve nested structured database of firebase". It read:

   How can I retrieve from nested database. The database structure is attached

After which, @antoinedupont (Antoine Dupont) added

    [code]
        firebase.database().ref('/requests').child(firstId).child(secondId).on('value', (snapshot) => {
            console.log(snapshot.val())
            // it should return the recipient and sender under the 'secondId'
        })
        
    [/code]
    
    Where:
    
      * firstId = W8MHvHBcNeU…
      * secondId = -Kz2bt9HqQh…

@Ayesha (Ayan Shah) replied

    firstId and secondId is not know …how can i get what's the firstid

So @antoinedupont (Antoine Dupont) replied

    The code I gave you shows how to retrieve nested data with firebase, so it answers your initial question.  
    What you really want to do is probably more complex, so you will need to explain exactly what you want to achieve (also from a user point of view).

Then @Ayesha (Ayan Shah) said

    I gave the structure of database from where i need to extract the value of sender and recipient. Basically I am trying to make a chat app and for this purpose “requests” table is for saving the requests send to the user. First id is the recipient id shows the request send to this user. Now i want to get the sender and recipient id to check that the request is sent to this user and now don't send the request again to this user

@TOrsini (T Orsini) replied

    Was there ever a solution found for this, where the firstId and secondId are unknown?

Then @mhartington (Mike Hartington) said

    


{'source': 'discourse', 'url': 'https://forum.ionicframework.com/t/retrieve-nested-structured-database-of-firebase/112360', 'title': 'Retrieve nested structured database of firebase', 'views': 1612, 'has_accepted_answer': False, 'word_count': 210, 'like_count': 0, 'reply_count': 4, 'participant_count': 3, 'posts': 7, 'tags': '', 'author': '@Ayesha (Ayan Shah)', 'participants': '@Ayesha (Ayan Shah), @antoinedupont (Antoine Dupont), @TOrsini (T Orsini), @mhartington (Mike Hartington)', 'image_url': ['https://global.discourse-cdn.com/ionicframework/original/3X/c/1/c1aa813088eced4affc5b4e03f51008183af099f.PNG'], 'created_at': '2017-11-16T11:05:56.469Z', 'last_posted_at': '2021-07-19T22:03:41.125Z'}