2

Assuming that I have the references of 4 documents, as follow:

users/user1/
preferences/user1
featureflags/user1
user_info/user1

how do I read all 4 documents in Firestore in a single request?

I tried with Promise.all as follow:

Promise.all([
    getUserInfo(user_id),
    getPreferences(user_id),
    getFeatureFlag(user_id),
    getUsers(user_id)
    ]
).then(function (ans) {
   //stuff
})

However, is there a better way?

TSR
  • 17,242
  • 27
  • 93
  • 197

1 Answers1

1

Querying across multiple collections isn't possible, so you are doing the best job by putting them together in 1 promise and read them later on. You could choose an other data structure.

Sending multiple request to the server isn't as slow as you might think. What you want is more SQL than NoSQL.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
J. Doe
  • 12,159
  • 9
  • 60
  • 114