Is it possible to retrieve multiple Firebase tables on one page?

I have been looking around everywhere for an answer to this question.
For those of you who use Firebase, is there any way to retrieve data from multiple tables (collections) and insert them into ONE page?

In my case, I have an Index page (part of a Vue application)

To get data from ONE Firebase collection, I can write.

db.collection('table1').get()

    .then(snapshot => {

      snapshot.forEach(doc => {

        let news = doc.data()

        tab1.id = doc.id

        this.table1.push(tab1)

      })

But what if I have a second collection called “table2” and I want to output it on the same page?
I cannot call db.collection twice, and I cannot write db.collection(‘table1’ + ‘table2’).get()

So how do I do this? (if its possible)

I don’t use Firebase, but because get returns a promise:

// Two promises:
const t1 = db.collection('table1').get();
const t2 = db.collection('table2').get();
// Promise.all resolves if both of those resolve:
Promise.all([t1, t2]).then(([snapshot1, snapshot2]) => {
  // result is an array of the resolved values
  // of t1 and t2.
  // Do stuff with them here, as in your function.
});
3 Likes