1
{
 "books" : {
"-KxIQCyLuvaAE1Mv2RaF" : {
  "author" : "test",
  "title" : "Please work"
},



db.list('books').valueChanges().subscribe((data)=>{
  //some code
})

I would like to grab the uid of a book object so that I can pass it to another component and just load that single book. I have looked everywhere, and there seems to be no easy way to do this

---EDIT--

that does not give me the keys from firebase

db.list('books').valueChanges().subscribe((data)=>{
  console.log(Object.keys(data));
})

results in

[18:55:47]  console.log: 0,1

I want the key: -KxIQCyLuvaAE1Mv2RaF

--EDIT 2--

I should read documentation,

.valueChanges()

strips metadata from the objects. I need

.snapshotChanges()
jamesim
  • 51
  • 1
  • 6
  • This is just pure JS and has nothing to do with Angular or angularfire, so I'll mark this as a duplicate. Answer based on your code, you can access the key with: `Object.keys(data.books)[0]` like suggested in duplicate :) – AT82 Oct 27 '17 at 08:17
  • Does not `.valueChanges()` return a "List" `[]` of the documents. Your console log would seem to indicate those "keys" are array indexes. So iterate the array returned and get the `Object.keys()` for each item. – Neil Lunn Oct 28 '17 at 13:28

0 Answers0