Idicious
01/23/2023, 8:48 AMts
const { data, error } = await this.supabase
.from('rooms')
.select('*, polls(*)')
.eq('name', name)
.maybeSingle();
// data has type similar to
type Data = {
id: string,
polls: Poll | Poll[] | null
} | null;
_Zaizen_
01/23/2023, 10:41 AMZerkia
01/23/2023, 12:40 PMAntDX316
01/23/2023, 12:40 PMCaptCuddleFish
01/23/2023, 1:59 PMdextah
01/23/2023, 2:31 PMwhere
clause to explicitly filter for not null
, but my generated types are still nullable.hachoter
01/23/2023, 2:33 PMimport { createClient } from '@supabase/auth-helpers-sveltekit';
import { PUBLIC_SUPABASE_ANON_KEY, PUBLIC_SUPABASE_URL } from '$env/static/public';
console.log('PUBLIC_SUPABASE_URL', PUBLIC_SUPABASE_URL);
export const client = createClient(PUBLIC_SUPABASE_URL, PUBLIC_SUPABASE_ANON_KEY);
The log shows the url, but in one file I get an error supabaseUrl is required
this is the full trace
client:dev: Error: supabaseUrl is required.
client:dev: at new SupabaseClient (/Users/isaac/Desktop/projects/all-simchas/node_modules/.pnpm/@supabase+supabase-js@2.4.1/node_modules/@supabase/supabase-js/dist/main/SupabaseClient.js:55:19)
client:dev: at Proxy.createClient (/Users/isaac/Desktop/projects/all-simchas/node_modules/.pnpm/@supabase+supabase-js@2.4.1/node_modules/@supabase/supabase-js/dist/main/index.js:35:12)
client:dev: at /Users/isaac/Desktop/projects/all-simchas/packages/utils/lib/client.ts:4:22
client:dev: at processTicksAndRejections (node:internal/process/task_queues:96:5)
client:dev: at async instantiateModule (file:///Users/isaac/Desktop/projects/all-simchas/node_modules/.pnpm/vite@4.0.0/node_modules/vite/dist/node/chunks/dep-ed9cb113.js:53246:9)
It's weird because in other files I am able to query even though it's the same client
this is the file that doesn't work
import { client } from '$lib/db';
import type { PageLoad } from './$types';
import type { Poster } from 'types/posters';
export const load: PageLoad = async ({ params }) => {
console.log('params', params);
const { data, error } = await client.from('posters').select().eq('id', params.id).single();
return {
poster: data
};
};
kuipou
01/23/2023, 3:15 PMYakkek
01/23/2023, 5:19 PMGregory
01/23/2023, 5:49 PM1voy
01/23/2023, 6:38 PMMopsior
01/23/2023, 6:40 PMToño
01/23/2023, 7:09 PMhotshoe
01/23/2023, 7:51 PMdebabrata
01/23/2023, 8:10 PMjs
useEffect(() => {
supabase.auth.onAuthStateChange(async (event, session) => {
if (event == "PASSWORD_RECOVERY") {
const newPassword = prompt("What would you like your new password to be?");
const { data, error } = await supabase.auth.updateUser({
password: newPassword || "",
})
if (data) alert("Password updated successfully!")
if (error) alert("There was an error updating your password.")
}
})
}, [])
Whenever I click on the password reset link that's sent in the email, I'm redirected to the proper page, but the page gets refreshed automatically and I can no longer accept the new password.Jaaneek
01/23/2023, 9:09 PMBrad Dwyer
01/23/2023, 9:13 PMGalen Winsor [gwinsor]
01/23/2023, 9:26 PM\copy
from the terminal, I get a canceling statement due to statement timeout
error. It looks like the maximum time for a query is 2 minutes; is there a way to increase this? Given the amount of data I'm trying to upload, I think it will take longer than 2 min.Dbugger
01/23/2023, 9:57 PMcreateClient
and I suspect that might have something to do with it (maybe no...), but I did not see any example of how to do this anywhere.
Anyone knows?Yakkek
01/23/2023, 10:27 PMAlanK
01/23/2023, 11:27 PMsmallint [] NOT NULL DEFAULT '{}'::smallint[]
When the trigger runs I get a
null value in column "stay_in_touch_choices" of relation "user_profile" violates not-null constraint
error.
Is there something I am missing?cayblood
01/24/2023, 12:22 AMGuy Rozen
01/24/2023, 12:34 AM.davdi
01/24/2023, 1:05 AMyayza_
01/24/2023, 1:53 AMjs
// hooks.server.js
export const handle = async ({ event, resolve }) => {
const { session, supabaseClient } = await getSupabase(event)
event.locals.supabase = supabaseClient
const authPaths = ['/login', '/register', '/verify', '/logout']
if (!session && !authPaths.includes(event.url.pathname)) {
throw redirect(302, '/login')
}
if (session && !authPaths.includes(event.url.pathname)) {
// use auth.refreshSession because it checks the db (auth.getSession doesn't)
const { data, error } = await supabaseClient.auth.refreshSession(session)
if (error) {
throw redirect(302, '/logout')
}
}
return resolve(event)
}
js
//+layout.server.js
import { getServerSession } from '@supabase/auth-helpers-sveltekit'
export const load = async (event) => {
const session = await getServerSession(event)
return { session }
}
zadlan
01/24/2023, 2:40 AMuser8923
01/24/2023, 5:02 AMChidhu
01/24/2023, 5:07 AMMuezz
01/24/2023, 6:52 AMsql
CREATE OR REPLACE FUNCTION upsert_meal(
arg_id_meal INT4,
arg_id_user UUID,
arg_name_meal VARCHAR,
arg_servings INT2
)
RETURNS INT4
SECURITY DEFINER
LANGUAGE plpgsql
AS
$$
DECLARE
meal_id INT4;
BEGIN
IF EXISTS (SELECT 1 FROM "Meal" WHERE "Meal".id_meal = arg_id_meal) THEN
UPDATE "Meal"
SET
"name_meal" = COALESCE(arg_name_meal, "Meal".name_meal),
"servings" = COALESCE(arg_servings, "Meal".servings)
WHERE "id_meal" = arg_id_meal
RETURNING "id_meal" INTO "meal_id";
RETURN "meal_id" AS "updated_meal_id";
ELSE
INSERT INTO "Meal"
("id_user", "name_meal", "servings")
VALUES
(
arg_id_user,
arg_name_meal,
arg_servings
)
RETURNING "id_meal" INTO "meal_id";
RETURN "meal_id" AS "new_meal_id";
END IF;
END;
$$;
Ape R Us
01/24/2023, 6:55 AMawait supabase.auth.updateUser({
data: { age: 20 }
});
in a +page.server.ts file (svelte)
the docs says that it needs to be in a json format.
what im trying to do is when a customer registers and logs in i want to automatically update their metadata to include the stripe id one time.