0

I am new in using firebase as backend to my flutter app and I have a question how to link two documents together and get both data at same time for example I have a user collection and post collection how I link both and when I get post data I also get user data in the same response

1 Answers1

1

Your objective looks like a JOIN query in a SQL database. Unfortunately, there is no JOIN query in Firestore - a NoSQL database. It is also mentioned in this answer that Firestore does not have the concept of a server-side JOIN.

There are ways that you can still do it like the following answers below:

  1. number one: You will have to query them individually then combine the two documents or to get data from multiple collections, you will need to perform multiple read operations. I think these are some examples of it: 1 2 3.
  2. number two: Remodeling your database that you can perform a Collection group query.
JM Gelilio
  • 3,482
  • 1
  • 11
  • 23