Lukas V
02/07/2023, 4:24 PMdefault_price
an offer price would be used during checkout.
Using first method, I would simply create 2 more columns offer_price_id
and offer_price_valid_until
, on my front end I would check if offer_price_until exists and timestamp is not expired, then I would render ui accordingly and would use offer price in the checkout.
Second method would be the same, but store both of these values in the single jsonb object.
Honestly it seems simple, but would i be missing something out in the future if I choose jsonb, maybe some queries such as list all users that have discounted subscriptions
Also, when discounts do expire, should I create automated task to "clean up" these values in the columns or not is it not necessary?monks1975
02/07/2023, 4:29 PMDomcario
02/07/2023, 5:14 PMpg_cron
supabase extension, but is it meant for a use case like this?wes_goulet
02/07/2023, 5:16 PM--forward-to
option that is used to develop/test locally. Anything like that available or coming to supabase cli?AntDX316
02/07/2023, 5:43 PMchickenmcnooble
02/07/2023, 5:46 PMhumblecoder
02/07/2023, 6:00 PMSupabase
instance running in Docker
. I can access Studio
and manipulate items from the UI. However, when I attempt to do anything "useful" from my NextJS
app with the supabase
object, (e.g. access authUrl
or storageUrl
) I receive a 404 Not Found
error.
Currently, the only change I've made to the configuration is changing Studio
to port 3131 (since the majority of my base applications already make use of 3000). I've tried the following for SUPABASE_URL
values:
- http://localhost
- http://localhost:3131
- http://localhost:8000
- http://localhost:9999
... none of them change the outcome. Hitting any of the auth/v1
endpoints always results in 404. Any chance we could get a detailed and precise writeup of how exactly the pieces fit together in Docker
without assuming default settings always?abaum
02/07/2023, 6:21 PMmansedan
02/07/2023, 6:38 PM(uid() = profile)
But we'd like to alter this so that we can also make updates from a Cron job that is running on a node-server that will occasionally poll & update the table.
How can we alter the policy, or set up the supabase-js client to be in an authenticated state?ali
02/07/2023, 6:58 PMWizzel
02/07/2023, 7:40 PMawill
02/07/2023, 7:57 PMjbergius
02/07/2023, 8:42 PMzeedee
02/07/2023, 9:32 PMjs
const fetchedPDF: any = await fetch(pdfUrl, {
method: 'GET'
})
.then(response => response.blob())
.then(blob => blob.arrayBuffer())
console.log("🚀 ~ file: supabaseClient.ts:126 ~ supabaseClientHandler ~ fetchedPDF", typeof fetchedPDF)
const { data, error } = await supabaseClient
.storage
.from('samsara-documents')
.upload(`fuel/${createDocument.data.id}.pdf`, base64.toString(fetchedPDF), {
upsert: true,
contentType: 'application/pdf'
})
If I understand it, I need to decode the url into a blob, then cast that into an arrayBuffer() When I decode it with the
import { base64 } from "https://cdn.jsdelivr.net/gh/hexagon/base64@1/src/base64.js";
library, nothing happens Is there a mistake here?DDupasquier
02/07/2023, 11:47 PMsql
BEGIN
IF NOT EXISTS (SELECT 1 FROM stories WHERE id = NEW."storyId") THEN
RAISE EXCEPTION 'Story with id % does not exist', NEW."storyId";
END IF;
UPDATE stories
SET likes = likes + 1
WHERE id = NEW."storyId";
RETURN;
END;
Pretty straight forward.
But I'm getting a syntax error from the UI?
Failed to create function: failed to update pg.functions with the given ID: missing expression at or near ";"
Not sure if I'm missing something lol. This looks perfectly fine, to me.Jim
02/07/2023, 11:47 PMroles
table. But struggling with the syntax:
sql
DROP TRIGGER on_auth_user_created ON auth.users;
create or replace function public.handle_new_user_role()
returns trigger as $$
begin
insert into public.roles (id)
values (new.id);
return new;
end;
create or replace function public.handle_new_user()
returns trigger as $$
begin
insert into public.profiles (id, full_name, avatar_url)
values (new.id, new.raw_user_meta_data->>'full_name', new.raw_user_meta_data->>'avatar_url');
return new;
end;
$$ language plpgsql security definer;
create trigger on_auth_user_created
after insert on auth.users
for each row execute procedure public.handle_new_user(), public.handle_new_user_role();
Im getting Failed to validate sql query: syntax error at or near "begin"
jinsley8
02/08/2023, 12:45 AMsql
select x.value->>'value' as value,
x.value->>'trait_type' as trait_type,
count(*)
from public.items,
lateral jsonb_array_elements(metadata->'attributes') as x
where x.value->>'trait_type' in ('coat_color', 'level', 'class')
group by value, trait_type
ORDER BY trait_type ASC;
My Function is like this right now. I want exactly what this select query above returns but this function is currently returning an error:
SELECT * FROM get_trait_count()
Failed to run sql query: query has no destination for result data
sql
CREATE OR REPLACE FUNCTION public.get_trait_count()
RETURNS setof items
AS $$
BEGIN
select x.value->>'value' as value,
x.value->>'trait_type' as trait_type,
count(*)
from public.items,
lateral jsonb_array_elements(metadata->'attributes') as x
where x.value->>'trait_type' in ('level', 'class')
group by value, trait_type
ORDER BY trait_type ASC;
END;
$$
LANGUAGE plpgsql
SECURITY DEFINER SET search_path = public;
oyinkan
02/08/2023, 12:53 AMnpm install
on windows 11 coming back with a node-gyp ERR
?
I've not found a way around it after trying some suggested solutions on the internet.
Any help will be appreciated, Thanks.suitedcode
02/08/2023, 3:19 AMconst { error: uploadError } = await supabase.storage
.from('attachments')
.upload(`${file.name}`, file, { upsert: true })
I've tested with policies enabled, I've tested by making the bucket public, but I keep getting a 500
server error.
I tested to make sure that the supabaseClient
is set up correctly. I'm able to list buckets successfully.
Any guidance or debug tips would be greatly appreciated. Please let me know if there are additional details I can provide if need be.nimo
02/08/2023, 3:19 AMError: ERROR: must be member of role "supabase_admin" (SQLSTATE 42501)
At statement 18: ALTER TYPE "public"."call_status" OWNER TO "supabase_admin"
It seems to be hotly debated (https://discord.com/channels/839993398554656828/1034366730593644565), but i'm not sure what immediate next steps are. Should I be editing the migration file directly and just change all lines that read:
ALTER TYPE "public"."call_status" OWNER TO "supabase_admin";
to read
ALTER TYPE "public"."call_status" OWNER TO "postgres";
?
How do you handle this longer term?sbr
02/08/2023, 3:43 AMJu Li
02/08/2023, 4:43 AMIsological
02/08/2023, 6:21 AMDisamDev
02/08/2023, 6:32 AMAntDX316
02/08/2023, 7:00 AMAmor Fati
02/08/2023, 7:29 AMauth.users
table but can't see how through the dashboard. I can see a way to do it using external SQL editors. Any thoughts on that?
Mainly I want to know if doing so will break anything or if it's fine.Dobroslav
02/08/2023, 8:42 AMmrmikardo
02/08/2023, 9:46 AMauth-helpers-sveltekit
to authenticate against a Supabase backend.
My issue boils down to the following: although I am authenticating with a test user at the start of the test, and then navigating to another page - against which I'm running some assertions - it appears that no session is being returned. And so the page under test isn't displayed.
What's particularly strange about this situation is that if I do npm run build && npm run preview
- which is what I do before running the Playwright tests - I am able to log in and access the page in question without issue.
Has anybody got any experience testing SvelteKit + Supabase apps with Playwright?jinsley8
02/08/2023, 10:02 AMmetadata
js
{
"attributes": [
{ "trait_type": "color", "value": "blue" },
{ "trait_type": "breed", "value": "herder" },
{ "trait_type": "gender", "value": "male" },
],
}
js
const { data, error } = await supabase
.from('items')
.select()
.eq('for_sale', true)
.contains('metadata->attributes', { color: "blue" })
-- this still isn't correct because "color" is the value of "trait_type" in the object.
It's responding with an error from the .contains() part. How can I get the matching data here?
Also, sometimes the query could have two values, how would I accomplish filtering with multiple string values for the same "trait_type"?
js
const query = "blue,red"
const splitQuery = query..split(', ')
const { data, error } = await supabase
.from('items')
.select()
.eq('for_sale', true)
.contains('metadata->attributes', { color: splitQuery }) // can I do an OR operator here?