eloahsam
03/18/2023, 7:32 PMVik
03/18/2023, 7:41 PMthosmos
03/18/2023, 8:06 PMpostgres
. Is there a way to change ownership of these tables to postgres? This seems like a bug.
postgres=> \dt
List of relations
Schema | Name | Type | Owner
--------+---------------+-------+----------------
public | customers | table | supabase_admin
public | dashtest | table | postgres
public | prices | table | supabase_admin
public | products | table | supabase_admin
public | subscriptions | table | supabase_admin
public | users | table | supabase_admin
(6 rows)
apost
03/18/2023, 8:09 PMVik
03/18/2023, 8:44 PMconst getPosts = async () => {
const { data, error } = await supabaseClient
.from('posts')
.select('post_id, created_at, content, asset_url, profile:user_id(*)')
.order('created_at', { ascending: false });
if (error) {
throw Error(error.message);
}
return data as unknown as Post[];
};
I want to add a filter so I only get the posts from followed users. The relationships table is setup as so:
approved: boolean;
created_at: string;
follow_id: string;
followee_id: string;
user_id: string;
Would love any feedback on this, one thing I haven't mastered. A valid follow is the auth.uid() = followee_id and approved = true.debrijja
03/18/2023, 10:01 PMSending fatal alert BadCertificate
TLS connection failed with message: invalid peer certificate contents: invalid peer certificate: UnknownIssuer
Defaulting to non-encrypted connection
Any way to suppress or fix it? Would still be nice to clean it up so other people checking the logs don't think there's a real problem.Raj Bennin
03/18/2023, 10:21 PMCELESTIALCITY
03/19/2023, 3:09 AMHypersigils
03/19/2023, 3:10 AM.from('table')
.select(`
id,
COALESCE(value, other_table.value)
`);
Jinx
03/19/2023, 4:27 AMSimon
03/19/2023, 5:40 AM(EXISTS ( SELECT 1
FROM chat
WHERE ((chat.id = message.chat_id) AND (chat.user_id = auth.uid()))))
However it fails on insert. I want to check if the chat which I reference with chat_id really belongs to the current authenticated user.anggoran
03/19/2023, 6:48 AMWamy
03/19/2023, 7:45 AMalekperos
03/19/2023, 9:12 AMchrismasters
03/19/2023, 9:43 AMplaylists
which has a column called first_play
which is a boolean and not null created with a migration like this
alter table "public"."playlists" add column "first_play" boolean not null default false;
Then the generated typescript definition file for the playlist
type looks like this
play_order: number
But if I then use this column in a view, ie
CREATE OR REPLACE VIEW public.tracklists AS
SELECT
playlists.first_play AS first_play
FROM playlists
Then first_play
in the view type is now nullable ie
first_play: boolean | null
Is there a way to prevent this from happening? Thanks!lea001
03/19/2023, 11:41 AMgleb
03/19/2023, 12:18 PMcreateBrowserSupabaseClient<Database>()
or createServerComponentSupabaseClient()
in TypeScript.bode
03/19/2023, 2:12 PMchrtravels
03/19/2023, 3:28 PMconst { data, error } = await supabase.auth.getSession()
However since the client side component isn't async, I put the call to getSession in an async function then called it in a useEffect:
useEffect(() => {
setSession(fetchSession().then(data => data));
}, [])
All I get in return is Promise {<fulfilled>: {…}}
It works when I do something similar to get a list of posts but not with getting the session. Any thoughts are appreciated.funkyj
03/19/2023, 4:47 PMspicypete
03/19/2023, 6:14 PMnext.js
(SSR off), tRPC
, prisma
, and supabase
.
My server uses createServerSupabaseClient
to get the auth context:
ts
// create the ctx variable for each tRPC procedure
export const createTRPCContext = (_opts: CreateNextContextOptions) => {
const { req, res } = _opts;
const supabase = createServerSupabaseClient<Database>({
req,
res,
});
return {
supabase,
...createInnerTRPCContext({}),
};
};
Which I then use in my tRPC procedures to sign in the user.
ts
export const authRouter = createTRPCRouter({
signIn: publicProcedure
.input(z.object({ phone: z.string() }))
.mutation(async ({ ctx, input }) => {
const { data, error } = await ctx.supabase.auth.signInWithOtp({
phone: input.phone,
});
return { data, error };
}),
verify: publicProcedure
.input(z.object({ phone: z.string(), token: z.string() }))
.mutation(async ({ input, ctx }) => {
const { data, error } = await ctx.supabase.auth.verifyOtp({
phone: input.phone,
token: input.token,
type: 'sms',
});
// ....
return { user, session: data.session, error };
})
})
On the frontend, I use createBrowserSupabaseClient
tsx
// _app.tsx
const App = ({
Component,
pageProps,
router,
}: AppProps<{initialSession: Session}>) => {
const [supabaseClient] = useState(() =>
createBrowserSupabaseClient<Database>({
supabaseUrl: clientEnv.NEXT_PUBLIC_SUPABASE_URL,
supabaseKey: clientEnv.NEXT_PUBLIC_SUPABASE_ANON_KEY,
}));
return (
<SessionContextProvider
supabaseClient={supabaseClient}
initialSession={pageProps.initialSession}
>
<Component {...pageProps} />
</SessionContextProvider>
)
}
export default api.withTRPC(App);
However, on my auth page,Mohamed Yasser
03/19/2023, 7:28 PMJinx
03/19/2023, 7:56 PMimagio
03/19/2023, 8:24 PMsupabase functions serve
to update the Deno cache. My local development is stuck with old cached versions of the files.
Deno cache -r locally does not fix it. Since it's run in a docker container I assume it's using a separate cache from my machine.
How can I get supabase functions serve
to refresh the Deno cache?DYELbrah
03/19/2023, 9:51 PMsignInWithPasword: publicProcedure
.input(
z.object({
email: z.string().email(),
password: z.string(),
})
)
.query(async ({ input, ctx }) => {
const supabase = ctx.supabase;
const { email, password } = input;
const {
data: { user, session },
error,
} = await supabase.auth.signInWithPassword({
email,
password,
});
if (error) {
throw new TRPCError({
code: "UNAUTHORIZED",
message: error.message,
});
}
}),
Somehow when my client calls this route from the front-end, if the login information is correct. the cookies are somehow being set? I figured I'd have to do that manually, but to my surprise I dont.
I don't have any of the supabaseBrowserClient or anything similar in my front-end.
How is the cookies being set?Amr
03/19/2023, 9:52 PMjs
const supabase = createClient(PUBLIC_SUPABASE_URL, SUPABASE_SERVICE_ROLE);
The delete function:
ts
async function deleteReservationByRefCode(refCode: string) {
const deleteQuery = await supabase
.from('reservations')
.delete()
.eq('ref_code', refCode.toUpperCase());
console.log(deleteQuery);
const selectQuery = await supabase
.from('reservations')
.select('id')
.eq('ref_code', refCode.toUpperCase());
console.log(selectQuery);
if (deleteQuery.error) {
console.error(deleteQuery.error);
return 'Internal error';
}
};
The console output is:
js
{
error: null,
data: null,
count: null,
status: 204,
statusText: 'No Content'
}
{
error: null,
data: [ { id: 7 } ],
count: null,
status: 200,
statusText: 'OK'
}
The row actually exists, but It can't be deleted!!
I also disabled RLS
just in case, and nothing changed!Sniped137
03/19/2023, 10:27 PMpy
email_exists = client.auth.table('users').select('*').eq('email', email).execute().get('data', [])
To access my users table in the auth scheme
It works usually for normal tablesDan Rumney
03/19/2023, 10:28 PMedge-runtime
but I can` t find a repo for that
Is there one?dmayo2
03/19/2023, 10:34 PMpublic
schema.
Right now I just have two different calls to db, but like to know if one call is doable. Thanks.
const { data, error } = await supabase
.from('auth.users')
.select(`email, profiles (first_name, last_name)`)
.eq('id', thisUser)
.single()
Error: Error fetching user profile: Could not find a relationship between 'auth.users' and 'profiles' in the schema cache