Back

Best way to store "Like", "Rate", and others stuff about a movie

  • 0
  • Databases
  • Web
loup
5 Jul, 2023, 07:39

Okay Im trying to build a kind of IMDB / TMDB app where user can like, mark as seen, etc... movie. So what the best way to store these datas ? Create one collection per type of reaction. For example :

  • Collection Movie_Rated
  • Collection Movie_Liked
  • Collection Movie_Watched

Or make only one collection like :

  • User_Movie where each document is contain a user id, movie id, if liked, if watched and if rated

idk what the best way, instinctively I would say the second one to get all data in one api call

TL;DR
The user is asking for the best way to store "like", "rate", and other similar actions for a movie in their app. They are considering creating separate collections for each type of reaction (e.g., Movie_Rated, Movie_Liked, Movie_Watched) or having one collection called User_Movie with documents containing user ID, movie ID, and the reaction details. They are also concerned about the possibility of a user liking a movie twice. The suggested solution is to create a function that increments the count when someone likes something and decrements it when the like is removed. This can be implemented using Appwrite functions. Overall,
D5
5 Jul, 2023, 10:26

Best way: create a function to add 1 when someone likes anything and remove 1 when like is removed

D5
5 Jul, 2023, 10:29

So you will need to have a likes collection to prevent the same user liking it 2 times

loup
5 Jul, 2023, 10:29

when u say a function, u are no talking about Appwrite function right ? So its better to have one collection per type of reaction ?

loup
5 Jul, 2023, 10:31

Mhh but if I have juste one collection with a document for each movie and each user example :

  • userId: 854d5g84dr25g54drg
  • movieId: 597
  • like: true
  • watched: true
  • rated: 8

How its possible to havbe an user liking 2 times ?

D5
5 Jul, 2023, 12:36

Yes, I'm talking about appwrite function

D5
5 Jul, 2023, 12:37

Respect to collection, yes, probably

D5
5 Jul, 2023, 12:38

The user creates 2 documents for the same film, so you get 2 likes

D5
5 Jul, 2023, 12:38

Instead, use a function that checks if it exists or not a document for the same film from the same user

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more