0

What is the best way to structure this data model and to query the data?

I got a Users collection and a Movie collection. I want to create a relationship between those 2 to indicate you've seen your movie. You can easily do that with the following collection:

watch_movies
  - user_id
    - movie_id => true
    - movie_id2 => true
  - user_id2
    - movie_id => true

But I also want to pick up the films that I have not seen yet. How can I best organize this, and which query is useful?

bastien
  • 2,940
  • 1
  • 13
  • 23
Jur Dekker
  • 151
  • 3
  • 11

1 Answers1

1

Firestore is not well suited for modeling data where a query must find things that don't exist. The way Firestore works is by indexing fields that do exist, and all queries will depend on finding things that exist in those indexes. Indexes simply can't find things that don't exist (because the universe of things that are unknown is extremely large!).

See also:

Consider using another database in tandem with Firestore to satisfy the queries that your app needs.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441