letourpowerscombine
11/29/2021, 4:45 PMusers can subscribe to pages and submit comments on pages. I have a users table, a pages table, a users_pages table, and a comments table.
I can currently pull a requested page, along with the users subscribed to it, with the following function. Is there anyway I can edit this to pull all of the comments for the requested page as well? Trying to fetch all of the page data in a single trip.
javascript
const { data, error } = await supabase
.from('pages')
.select(`*, users(id, email)`)
.eq('slug', request.body.get('slug'))silentworks
11/29/2021, 4:48 PMjs
const { data, error } = await supabase
.from('pages')
.select(`*, users(id, email), comments(*)`)
.eq('slug', request.body.get('slug'))letourpowerscombine
11/29/2021, 4:51 PMjavascript
{
message: 'More than one relationship was found for pages and users',
hint: "By following the 'details' key, disambiguate the request by changing the url to /origin?select=relationship(*) or /origin?select=target!relationship(*)",
details: [
{
relationship: 'public.users_pages[users_pages_page_id_fkey][users_pages_user_id_fkey]',
cardinality: 'm2m',
origin: 'public.pages',
target: 'public.users'
},
{
relationship: 'public.comments[comments_page_id_fkey][artifacts_user_id_fkey]',
cardinality: 'm2m',
origin: 'public.pages',
target: 'public.users'
}
]
}letourpowerscombine
11/29/2021, 6:04 PMsilentworks
11/30/2021, 2:59 PMsilentworks
11/30/2021, 3:00 PMletourpowerscombine
11/30/2021, 4:31 PMSteve
12/01/2021, 7:14 PMSteve
12/01/2021, 7:17 PMjs
const { data, error } = await supabase
.from('pages')
.select(`*, users!users_pages(id, email), comments(*)`)
.eq('slug', request.body.get('slug'))letourpowerscombine
12/03/2021, 9:49 AM