Back

[SOLVED] Add index with "relationship" type Attribut

  • 0
  • Web
loup
8 Jul, 2023, 15:56

Okay ive just created a movie_liked collection where each document contain :

  • movieId : integer
  • userId : relationship attribut with the usercollection

But when I try to add an index call isMovieLiked with these attribut movieId and userId. I cant add the userId attribut he dont appear

TL;DR
The user is confused about using a "relationship" type attribute in a collection. They wanted to check if a user has already liked a playlist and were considering making the attribute in the movie_liked collection a relationship. They discovered that they need to check if the user has already liked the post to prevent duplicate likes. They solved the issue by adding an index with a "relationship" type attribute for userId and movieId. They realized there is no need to make an index with a relationship attribute. They created a movie_liked collection with movieId and userId attributes, but faced an issue when trying to add an index called "isMovieLiked
loup
8 Jul, 2023, 16:11

or I can add another userId attribut with string type

Drake
8 Jul, 2023, 17:07

There's no need to make an index with a relationship attribute

loup
9 Jul, 2023, 08:54

Im kidna lost, I was thinking a relationship attribute was a normal attribut but with a connected value. Like in my case for the movie_liked collection, i have :

  • movieId : integer
  • userId : relationship attribut with the usercollection

So I want to be able to get the movie liked by an user so I need an index with movieId AND userId right ?

loup
9 Jul, 2023, 08:55

Or relationship isnt a value, but just a way to link documents each others ?

Drake
9 Jul, 2023, 19:12

Did you try to query? What happened?

loup
9 Jul, 2023, 19:44

So sorry that my bad

loup
9 Jul, 2023, 19:44

Its working perfectly with userId (relationship attribut) and movieId

loup
9 Jul, 2023, 19:44

[SOLVED] Add index with "relationship" type Attribut

loup
10 Jul, 2023, 21:18

Update: I finally have to check everytime if user already like the post or not to prevent duplicate like u was right

Drake
11 Jul, 2023, 02:07

Huh?

loup
11 Jul, 2023, 13:21

Sry I was just saying that when an user like a playlist, I have to check if this same user has already liked the playlist

Drake
11 Jul, 2023, 15:35

hmmmmmmm i see....i wonder if it's worth it to make the attribute in the movie_liked collection a relationship then..

Drake
11 Jul, 2023, 15:35

btw, you might want to 👍🏼 this issue: https://github.com/appwrite/appwrite/issues/5400

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