List all documents in a Firebase collection

July 29, 2018

You can list all of the documents in a Firebase collection like so:

firestore
  .collection('yourCollectionName')
  .onSnapshot(querySnapshot => {
    const results = []
    querySnapshot.forEach(document => {
      let item = document.data()
      results.push(item)
    })

    // Now, do whatever you want with your data:
    console.log(results)

  })

Want more?

My newsletter sends rarely. It's where I share updates on the best of my writing: introverted entrepreneurship, esoteric mindset tips, notes from great books, and automating businesses as a solo-owner so they run by themselves. Want to join?

Subscribe