I have two separate supabase calls ```const ...
# help
e
I have two separate supabase calls
Copy code
const { data: mutualReviews, error: mutualError } = await supabase
        .from('reviews')
        .select('score, text, profiles!inner(*)')
        .eq('video_id', id)
        .neq('user_id', user.id)
        .in('profiles.twitter_handle', profile.twitter_follows)
        .contains('profiles.twitter_follows', [profile.twitter_handle])

      const { data: followsReviews, error: followsError } = await supabase
        .from('reviews')
        .select('score, text, profiles!inner(*)')
        .eq('video_id', id)
        .neq('user_id', user.id)
        .in('profiles.twitter_handle', profile.twitter_follows)
        .not('profiles.twitter_follows', 'contains', [profile.twitter_handle])
The only differentiating line is the final one, contains vs not. In this context not does not work at all. I think that maybe it only works for 'eq'?
g
well postgrest thinks it should: "To negate any operator, you can prefix it with not"... I've not tried on contains but it is supposed to work
I would test it by itself with just the contains, and see if you get the results you expect. It is possible all your filters result in no results, especially if nulls get involved.
e
I did try it just by itself
It seems to not work for at least contains, by itself
g
@User OK so looking at the supabase.js URL being generated for .not and what postgrest wants............. ta da! .not('tags','cs','{b,a}') works... LOL cs makes sense as that is what postgrest expects for contains... '{b,a}' works as a replacement for ['b','a'] used in the .contains. There maybe other ways to format that part. Key is the 'cs' instead of contains and then just getting an array with %7b and %7D to replace [] as brackets for the array in the URL which is what postgrest wants....
e
Wow thanks for the reply @User
The only part I don't follow is how I would replace ['b', 'a'] with '{b, a}' in this scenario:
.not('profiles.twitter_follows', 'cs', profile.twitter_handle)
The part that needs to be changed in this case is on the left
Can I pull off this
%7D
trick on
'profiles.twitter_follows'
which is an array on the left?
I've never heard of this before
g
The left part is the column name, the right part is a js array with your values... not a column... .contains['col',[a,b,c]) 'col' is a column in your table that is an array type.
e
Hm in this case the right part is just a single string
For contains
Would be the opposite for in
g
It is an array with one or more values to check if in the database col that is also an array
e
Oh okay
Sorry if I'm being ignorant
I see what you mean thank you
g
.in is totally different it compares a single value column to see if an array has that value in it.
I guess the code above would handle a foreign column, but not sure.
e
I see
g
Good luck. Night.
e
Thank you!!
That worked oh my god
Thank you so much @User - you get a special VIP badge on my side project whenever it launches this made my night 🙏