bpeck81_
02/24/2023, 6:51 PMGravy
02/24/2023, 7:54 PMGregory
02/24/2023, 8:19 PMconsole.log('API key =', Deno.env.get('OPENAI_API_KEY'));
API key = undefined
Should I just hardcode it into the edge function?jt
02/24/2023, 9:11 PMMarcMartin
02/24/2023, 9:28 PMJoshTheNerd
02/24/2023, 9:38 PMParanoidCoder
02/24/2023, 9:46 PMmohnish
02/24/2023, 10:44 PMDomcario
02/24/2023, 11:52 PMsubevents
with jsonb column assigned_to
. given array of javascript objects, i would like to filter for value.uuid
= someUUID
[
{
"label": "adfscxz",
"value": {
"uuid": "2238957c-7d05-48fb-b829-6c3221015068",
"email": "vcxbcvbx@vcxbcvbx.com",
"phone": "",
"last_name": "ewtterw",
"company_id": "c68f4ea0-9b31-4105-91dd-48627cea08df",
"created_at": "2022-11-03T20:02:14.897281+00:00",
"first_name": "bvnnb",
"favorite_url": "/dd/The-Planning-Company/221",
"email_verified": true,
"phone_verified": false,
"profile_pic_url": " vc bvc cbv.com/a/AEdFTp5g6U2HnEAdIgCv34qyf5h1eK-uMiPCTHJf0v4cXg=s96-c"
},
"disabled": false
},
{
"label": "adfscxz",
"value": {
"uuid": "f1d9710b-a145-44ea-a00f-87b7740ed272",
"email": "mkandan@asu.edu",
"phone": "+14808531003",
"last_name": "ewtterw",
"company_id": "c68f4ea0-9b31-4105-91dd-48627cea08df",
"created_at": "2023-02-08T14:53:49+00:00",
"first_name": "bvnnb",
"favorite_url": "/dd/The-Planning-Company/222",
"email_verified": true,
"phone_verified": false,
"profile_pic_url": " vc bvc cbv.com/a/AEdFTp4isLRCN73tmGrPqK7RSOE1jO3qCM_8tF7FNJgVvw=s96-c"
},
"disabled": false
}
]
js
const { data: subeventData, subeventError } = await supabase
.from('subevents')
.select()
.eq('assigned_to->value->uuid', "2238957c-7d05-48fb-b829-6c3221015068")
Benanna19
02/25/2023, 12:24 AMJoshTheNerd
02/25/2023, 2:29 AMsql
SELECT
CASE WHEN EXISTS
(SELECT
*
FROM
"Messages"
WHERE "conversation_id" = (SELECT
conversation_id
FROM
"Conversations"
WHERE "author_id" = auth.uid() OR "contact_id" = auth.uid() )
AND author_id NOT IN (auth.uid()))
THEN true
ELSE false
END
Noah Burroughs
02/25/2023, 3:08 AMjinsley8
02/25/2023, 4:14 AMHolland
02/25/2023, 5:47 AMexport const getServerSideProps: GetServerSideProps = async (ctx) => {
// Create authenticated Supabase Client
const supabase = createServerSupabaseClient(ctx)
// Check if we have a session
const {
data: { session },
} = await supabase.auth.getSession()
console.log('session', session)
if (!session)
return {
redirect: {
destination: '/login',
permanent: false,
},
}
return {
props: {},
}
}
When redirecting on google sign in, session is null for some reason. When I refresh the page I magically get a session and the user appears to me and I can access the protected route. I am using next js.swiftarrow
02/25/2023, 7:06 AMmisakss
02/25/2023, 10:15 AMImJune
02/25/2023, 10:37 AMCREATE POLICY "Enable insert for authenticated users only" ON "public"."Ebooks"
AS PERMISSIVE FOR INSERT
TO authenticated
WITH CHECK (auth.uid() = user)
it throws this error
Error adding policy: failed to create pg.policies: operator does not exist: uuid = nameError adding policy: failed to create pg.policies: operator does not exist: uuid = name
any help would be great, thanksrattlesnake
02/25/2023, 11:31 AMeloahsam
02/25/2023, 11:49 AMAlaanor
02/25/2023, 12:13 PMzngb
02/25/2023, 12:50 PMsaswatsaubhagya
02/25/2023, 1:04 PMmrmikardo
02/25/2023, 1:40 PMauth.users
with the following snippet;
INSERT INTO auth.users (id, instance_id, aud, role, email, encrypted_password, email_confirmed_at)
VALUES (
gen_random_uuid(),
gen_random_uuid(),
'authenticated',
'authenticated',
'test_user@witihpluto.com',
crypt('password', gen_salt('bf')), <-- this is the line I am unsure about!
now()
);
I can see that users are successfully inserted with a hashed password. However, when I later try and log this user in via the Supabase JS client, I'm getting an error from the database.CauaLW
02/25/2023, 3:30 PMFuture<ReturnData> searchPatients(String param) async {
try {
List<Patient> searchedPatients = await _table.select().eq('user_id', UserProvider().user.id).ilike('name', '%$param%').order('id').limit(5).withConverter<List<Patient>>((patientsList) => patientsList
.map<Patient>(
(p) => Patient.fromJson(p),
)
.toList());
return ReturnData(isOk: true, message: '', data: searchedPatients);
} catch (e, s) {
if (kDebugMode) {
print('Error on searchPatients: $e');
print(s);
}
return ReturnData(isOk: false, message: 'Ocorreu um erro ao buscar os pacientes, por favor tente novamente mais tarde');
}
}
and here is the error I'm facing: PostgrestException(message: JSON object requested, multiple (or no) rows returned, code: PGRST116, details: Results contain 5 rows, application/vnd.pgrst.object+json requires 1 row, hint: null)jumeh
02/25/2023, 3:30 PMjfischoff
02/25/2023, 4:46 PMGrimmjoww231
02/25/2023, 4:54 PMCheqo
02/25/2023, 5:00 PMsupabase-admin.ts
file is in the utils folder. That means it's being used client side and is exposed?
Am i missing something or is it okay to use it like this? here is the link of the file.
https://github.com/vercel/nextjs-subscription-payments/blob/main/utils/supabase-admin.tsdrunkenxwizard
02/25/2023, 5:03 PMUsers
table in the public
schema
- Used to triggers and functions mentioned here (https://github.com/supabase/supabase/discussions/7659#discussioncomment-4475351) to insert rows into this public.Users
table
- To be sure that these functions and triggers are saved in GitHub, I added them to the top of the initial migration file β π¨ I believe this is the cause of the issue
*This discussion helped me quite a bit: https://github.com/supabase/supabase/discussions/7659 - thank you @NanoBit! *
β
All of that is working fine
The issue:
- I Updated the schema.prisma
file to insert a new model
- I want this to be recorded as a "migration" so I ran npx prisma migrate dev --name add-api-keys
At this point, I run into an error:
Migration `20230225153045_init` failed to apply cleanly to the shadow database.
Error:
db error: ERROR: schema "auth" does not exist
0: migration_core::state::DevDiagnostic
at migration-engine/core/src/state.rs:269
This, of course, makes sense as the shadow DB won't have any idea of the auth
schema.
My question:
Am I approaching this incorrectly?
If you have Supabase auth + Prisma working, what approach have you followed?
Thank you so much!Holland
02/25/2023, 5:26 PMtype PostsResponse = Post & {
users: {
first_name: string | null
last_name: string | null
}
}
const { data, error } = await supabase.from('posts').select(`
post_id,
title,
content,
likes,
user_id,
users(
first_name,
last_name
)
`)
I have a subscription listening for new posts. What is the best way to get a subscription event then join it with data from another table?
Here is what I have:
postsSubscription = supabase
.channel('custom-insert-channel')
.on(
'postgres_changes',
{ event: 'INSERT', schema: 'public', table: 'posts' },
(payload) => {
console.log('Change received!', payload)
}
)
.subscribe()
Should I do another call inside the payload function to join the tables and get the data I need? I'm using nextjs and typescript.