javascript - How to get the key from a Firebase data snapshot? - Stack Overflow
Fri May 26 2023 17:05:11 GMT+0000 (Coordinated Universal Time)
Saved by
@raca12
this.app.firestore()
.collection('collection')
.doc('document')
.onSnapshot(function(snapshot) {
const id = snapshot.id;
//----------OR----------//
const data = snapshot.data() || null;
if (data) {
const id = Object.keys(data)[0];
}
});
content_copyCOPY
https://stackoverflow.com/questions/43615466/how-to-get-the-key-from-a-firebase-data-snapshot
Comments