I’m using Supabase and basically I need the equivalent of this SQL statement using supabase JS client.
SELECT * from ratings
JOIN users ON ratings.user_id = users.id
JOIN cafes ON ratings.cafe_id = cafes.id
WHERE cafe_id = 70 AND user_id = 'a8d15462xxxxxx'
Extended Info:
I have 3 tables:
users (id – primary key)
cafes (id – primary key)
ratings (id – primary key; user_id – foreign key users; cafe_id: foreign key cafes).
Tried many things, most common error was “Could not embed because more than one relationship was found for ‘ratings’ and ‘cafe_id'”,
for example when trying
const {data, error} = await supabase
.from('ratings')
.select(
`
*,
cafes: cafe_id("*"),
users: user_id("*")
`
)
Using supabase sql editor I can get the intended result but unfortunately I’m unable to figure out how to get the same result with the supabase api. Could anyone help? Many thanks in advance!
Hugo Carvalho is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.