{
\"users\":{
\"userid_1\":{
\"following\":{
\"userid_2\":{
\"name\":\"user2\"
},
\"userid
Firestore does not have the concept of a server-side JOIN. All documents in a single read operation must come from the same collection.
That means that to get data from multiple collections, you will need to perform multiple read operations - at least one per collection, but possibly more. This is normal in most NoSQL databases, and not nearly as slow as many developers think for the amount of data you should read from a client-side app.
If the number of documents you need to read is prohibitive for your application, consider changing your data model to require fewer reads. Typically this means that you'll end up duplicating some of the data into a format that is more easy to read.
For example in your use-case you seem to have a social network. A common solution there is to store the complete feed for each user, so all the posts for people they follow, as a separate collection in the database.
So when a user writes a post, you write that post to the main posts
collection, and also to the feed
collection of each user that follows them. This operation is known as fanning out your data, and while it complicates the write operation and duplicates data, it makes the code that reads the data simpler, and much more scalable. Since in many applications read operations are far more common than write operations, many NoSQL data modelers consider this a valid trade-off.
This topic is incredibly broad and hard to do justice in a single answer, which is why I recommend you also: