How can I create a data model with Firebase that supports instagram story features?

Cloud Firestore

Lets say I want to have a data structure like this in firestore:

Collection

Users -> User(Doc) - User info such as name, birthday, posts user has liked, etc.

Stories -> Story(Doc) - Story info such as title, descript, date, etc.

Medias(SubCollection of Stories) -> Media(Doc) - Media url, date, created by, is video, etc.

Where would I store data such as who viewed a media? An array of UIDs inside of Medias wont work because there is no way to query all the medias that a user has not viewed. (There is no query for array does not contain)

​

Also I am using Swift, not that it really matters but the queries are written slightly different.

Posted May 4, 2022, 1:48 AM UTC

96
Loading comments…