SGreen
05/02/2023, 11:33 AMPushpalatha
05/02/2023, 11:34 AMKilltec
05/02/2023, 1:14 PMprattjc
05/02/2023, 2:38 PMhttps://cdn.discordapp.com/attachments/1102967457402060891/1102967457620168714/image.png▾
vick
05/02/2023, 2:54 PMB-Train
05/02/2023, 3:09 PMIrvingOu
05/02/2023, 3:10 PMRevaycolizer
05/02/2023, 3:14 PMvonrie
05/02/2023, 3:25 PMor
operation for ilike
supabaseClient.from('analyzers').select('id,name,imgUrl,manufacturers(name),departments(name,labs(name)),tests(count)').or('name.ilike.%org%,manufacturers.name.ilike.%org%')
Kasoa
05/02/2023, 3:34 PMYourAverageTechBro
05/02/2023, 3:45 PMuseUser
function and it is causing my component to infinitely re-render.
I've attached an image with an example component.
I verified the loop by adding a console.log("hello")
and when I comment out the useUser()
call it does not loop infinitely but when I remove the comment it does cause an infinite loop.
Is there something that I'm missing that is causing this infinite loop? I've never had this issue in other projects that I've used Supabase for.
https://cdn.discordapp.com/attachments/1102984311818436651/1102984312732790944/Screenshot_2023-05-02_at_10.43.59_AM.png▾
Grantly
05/02/2023, 3:57 PM클로버
05/02/2023, 4:30 PMHugos
05/02/2023, 4:42 PMsql
CREATE OR REPLACE FUNCTION check_duplicate_product() RETURNS TRIGGER AS $$
BEGIN
IF EXISTS (
SELECT 1 FROM products WHERE name = NEW.name AND size = NEW.size AND (id IS DISTINCT FROM NEW.id)
) THEN
RAISE EXCEPTION 'Product with same name and size already exists';
ELSE
RETURN NEW;
END IF;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER check_duplicate_product_trigger
BEFORE INSERT OR UPDATE ON public.products
FOR EACH ROW
EXECUTE FUNCTION check_duplicate_product();
Basically what I want is when a new Product row is inserted I want to verify that the name and size arent the same as any other row
So if my existing table has a product with name: 'test' and size: 'small'
The function should trigger when another product is insert where the name is 'test' and the size is 'small' if any of these 2 do not match, then there shouldn't be any exception.
When I tested my above sql it does create the function and trigger but does not raise an exception when I tried to raise one by giving a duplicate record (except id)Defhunt
05/02/2023, 4:58 PMnpx supabase gen types typescript --project-id \"SOME_ID\" > src/types/supabase-types.ts
Is there a way I can resolve this?
https://cdn.discordapp.com/attachments/1103002660015198260/1103002660380098610/Screenshot_2023-05-02_at_12.38.43_PM.png▾
https://cdn.discordapp.com/attachments/1103002660015198260/1103002660740812810/Screenshot_2023-05-02_at_12.30.13_PM.png▾
altryne
05/02/2023, 5:09 PM├─┬ @nuxtjs/supabase@0.3.5
│ ├─┬ @supabase/supabase-js@2.13.1
│ │ ├── @supabase/functions-js@2.1.1
│ │ ├── @supabase/gotrue-js@2.24.0
│ │ ├── @supabase/postgrest-js@1.6.0
│ │ ├── @supabase/realtime-js@2.7.2
│ │ ├── @supabase/storage-js@2.5.1
Implementation:
Code that sends the OTP (and magic link)
const { error } = await supabase.auth.signInWithOtp(
{ email: email },
{
redirectTo: `${window.location.origin}${redirect || '/dashboard'}`
})
Code that verifies (and fails) when user enters it
const { data, error } = await supabase.auth.verifyOtp({ email: otpModalOptions.value.email, token: code.value, type: 'magiclink'})
if (error){
code.value = ''
errorOtp.value = true
https://cdn.discordapp.com/attachments/1103005267899195392/1103005268138266705/CleanShot_2023-05-02_at_10.36.032x.png▾
https://cdn.discordapp.com/attachments/1103005267899195392/1103005268566081606/CleanShot_2023-05-02_at_10.22.362x.png▾
https://cdn.discordapp.com/attachments/1103005267899195392/1103005268889051207/CleanShot_2023-05-02_at_11.04.542x.png▾
https://cdn.discordapp.com/attachments/1103005267899195392/1103005269270728755/image.png▾
draco
05/02/2023, 5:23 PM.ilike
function from js?
I know that i can accomplish it with sql if I do something like the following
select * from some_table where column ilike all(array['val_1', 'val_2'])
what I want to do is something like the following
supabase.from('some_table').select().ilike('column', '%['val_1', 'val_2']%')
Is this possible or would I have to us .or()
and do lots of string concatenations for each element in an array to look like column.ilike.${array_entry_value}
What I am trying to achieve is to do a case insensitive search for multiple text values in a table. If I use a filter like .in()
it will do exact matches, but that is not ideal so ilike
is the best optionMusashiGarami
05/02/2023, 5:29 PMMuspi Merol
05/02/2023, 5:41 PMmalphine2
05/02/2023, 5:43 PMturulix
05/02/2023, 6:04 PMSomeone.
05/02/2023, 6:33 PMhttp://localhost:3000/#access_token=[token]&expires_in=3600&refresh_token=[token]&token_type=bearer&type=invite
crimsen
05/02/2023, 7:20 PMhttps://cdn.discordapp.com/attachments/1103038214228410368/1103038214341660672/disshot.png▾
malachi
05/02/2023, 7:40 PMnickbryant.fyi
05/02/2023, 8:31 PM// Define the API route handler
export default async (req, res) => {
// Check if the request method is POST
if (req.method === 'POST') {
// Extract the message from the request body
const { message, chatHistory } = req.body;
const supabaseServerClient = createServerSupabaseClient<Database>({
req,
res,
});
const {
data: { session },
} = await supabaseServerClient.auth.getSession();
const {
data: { user },
} = await supabaseServerClient.auth.getUser();
console.log('session', session, 'user', user);
This is how I'm invoking the nextjs API:
import { supabase } from 'lib/Store';
export const apiCall = async (endpoint, method, payload) => {
const session = await supabase.auth.getSession();
const options = {
method: method.toUpperCase(),
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${session.data.session.access_token}`,
},
body: '',
};
console.log
if (payload) {
options.body = JSON.stringify(payload);
}
const response = await fetch(endpoint, options);
const data = await response.json();
return data;
};
export default apiCall;
Working based off of the slack clone starter.BinaryBench
05/02/2023, 9:02 PM/register-form
, unless I'm already on the /register-form
page:
This works, however it still logs PGRST116
errors to the console:
javascript
try {
const { data: profile, error } = await supabase
.from('profiles')
.select('*')
.eq('id', userResponse.data.user.id)
.single();
if (error) {
throw error;
}
return profile;
} catch (e) {
if (e.code && e.code == 'PGRST116') {
if (pathname !== '/register-form') {
router.push('/register-form');
}
return null;
}
throw e;
}
What am I doing wrong here?crimsen
05/02/2023, 9:18 PMhttps://cdn.discordapp.com/attachments/1103067987935776830/1103067988141277184/s1.png▾
https://cdn.discordapp.com/attachments/1103067987935776830/1103067988481028197/s2.png▾
hko
05/02/2023, 10:13 PM{
"email": "iamasupabase@user.com"
}
and then do something like
supabaseServiceRole.from("user_emails").select("user_id").eq("email":email)
supabaseServiceRole.assumeRole(user_id);
// continue requests in the same way as if coming from the logged in client
It seems like most solutions I found rely on a JWT being passed, but I cannot do that.KiwiHour
05/02/2023, 10:50 PMgetSession()
instead of getUser()
, but that was returning null too.
So I used setSession()
The session I use to set it has valid information in, but the next line i get the session to check its been set, and its null again.
Whats going wrong?
https://cdn.discordapp.com/attachments/1103091216654028861/1103091216784031974/image.png▾
https://cdn.discordapp.com/attachments/1103091216654028861/1103091217065054208/image.png▾