I'm running Supabase locally, using Docker, on MacOS. I initialized a Next.js project with Supabase, and connected the locally created database to JetBrains DataGrip. I can see and adjust the data in DataGrip without issue. But when I try to query the data from my app's API, I get an error that 'relation "public.users" does not exist'
However the users
table I have is within the public schema. So I'm not quite sure why it doesn't exist when I try to access it with the API.
In DataGrip, my database file structure is:
postgres@localhost > postgres > schemas > public > tables > users
My app uses the Supabase client to connect:
import { createClient } from '@supabase/supabase-js'
const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL
const supabaseAnonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY
export const supabase = createClient(supabaseUrl, supabaseAnonKey)
The API call I'm using to access the data is:
async function getData(req, res) {
try {
let { data, error, status } = await supabase
.from('users')
.select()
if (data) {
res.status(200).json({ data })
}
} catch (error) {
res.send(error)
}
}
Just in case there was some sort of naming collision with the users table a hosted Supabase db uses, I also tried the above with an accounts
table as well, but that did not have any impact.