'Firebase RTDB - Get document ID?

how can i retrieve document IDs in a useEffect using firebase realtime database?

This works great but however i need every single document id aswell. enter image description here

enter image description here



Solution 1:[1]

This is how you can get keys from array in RTDB:

onValue(dbRef, (snapshot) => {
  snapshot.forEach((childSnapshot) => {
    const childKey = childSnapshot.key;
    const childData = childSnapshot.val();
    // ...
  });
}, {
  onlyOnce: true
});

You need to get to childSnapshots using forEach or for loop.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mises