Supabase postgres() & createClient() connection both in the same node server

Hello,

Question: Is this a good thing to do? Which of the one method is recommended if this is a bad idea. Please let me know.

Overview :
I have create the below file db.connect.ts where I have exported both direct connect & api connect methods.
// API Connect
const { supabaseUrl, supabaseKey } = config.dbConfig;
export const supabase = createClient(supabaseUrl!, supabaseKey!);

// Direct Connect using Postgres
const { supabaseDirectUrl } = config.dbConfig;
export const sql = postgres(supabaseDirectUrl!);


Now I can use both functionalities anywhere in my app. Incase I want to raw dog SQL, I can just use sqlselect * from users; else i can use await supabase.from("users").select('*').

I did this because i wasn't able to use complex joins using the api connect. So i can use any one of them when needed.
Was this page helpful?