I'm planning the structure of my DB for a project using Cloud Firestore, and I'm currently trying to figure out the best approach to storing data and associating it to users. The specifics are as follows:
I have a collection of user documents at the root of my DB, and I want users to be able to make posts that are accessible both by looking at a user profile page which displays posts by that user, and in aggregate by looking at a page displaying posts by all users.
Storing a user's posts in a sub-collection of the user document would make it very easy to fetch a user's posts for their profile, but is it possible to write an elegant query that merges every user's post sub-collections into one result set?
Or would a better approach to be to have another collection in the root of my called posts, and have a field on each post containing the user's UID or a denormalized copy of the user document?