rlightner
11/08/2022, 12:23 AM.returns<{ stripe_customer_id: string | null }>()
but its not respecting this for some reasonlewisd
11/08/2022, 1:06 AMLukas
11/08/2022, 2:48 AM((()))
11/08/2022, 5:01 AMKhalifa007
11/08/2022, 6:52 AMconst { data, error } = await supabase
.from('users')
.select(`*`)
.eq('id', id)
.limit(1)
.single()
pvineet44
11/08/2022, 7:02 AMkvnfo
11/08/2022, 8:18 AMwolf5
11/08/2022, 8:24 AMalx90
11/08/2022, 8:54 AMconst { data, error } = await supabase
.from("Articles")
.select()
.eq("URL", pageSlug)
.match({ BlogId: blogId });
Result is [] <-- Im totally sure my blogId and my URL, pageSlug are identical.
Some help maybe :D?Relisora
11/08/2022, 11:37 AM"id" "name" "rank" "grade"
111204161931972608 "reli" 12 5001
Request:
js
let {data} = await supabase
.from("User")
.select("*")
Response:
js
{ id: 111204161931972600, name: 'reli', grade: 5001, rank: 12 }
See how my user id got rounded for the decimals?Kenbak
11/08/2022, 12:00 PMconfig_wizard
11/08/2022, 1:18 PMcurl --location --request GET 'https://unique-code.supabase.co/rest/v1/table_name' \
--header 'apikey: eyJhbGciOiJIUzI1NiIs-apikey' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIs-apikey'
{"code":"42501","details":null,"hint":null,"message":"permission denied for table categories"}
is there anything else that I could have missed?peak
11/08/2022, 1:57 PMHermes
11/08/2022, 2:59 PMZaDeR47
11/08/2022, 3:09 PMsql
create function create_new_post("userId" uuid, "title" text, "content" text)
returns boolean
language plpgsql
as $$
begin
with "insertedPost" as (
insert into posts ("user_id", "path") values ($1, 'root')
returning "id"
)
insert into post_contents
("post_id", "title", "content") values
((select "id" from "insertedPost"), $2, $3);
insert into post_score
("post_id", "score") values
((select "id" from "insertedPost"), 0);
commit;
return true;
end; $$
When I call the rpc from the supabse client, I'm getting the error "Relation \"insertedPost\" does not exist".
Can anyone see what I'm doing wrong here?Yuito
11/08/2022, 4:29 PMdrewbie
11/08/2022, 5:50 PMorders
table that has a buyer_id
and a seller_id
, both referencing/associated with the accounts
table. That part so far is fine
CREATE TABLE orders
(
id uuid default uuid_generate_v4() primary key,
created_at timestamp default now() not null,
updated_at timestamp default now() not null,
state "order_state" default 'IN_PROGRESS' not null
);
ALTER TABLE "orders" ADD COLUMN "buyer_id" UUID NOT NULL;
ALTER TABLE "orders" ADD CONSTRAINT "orders_buyer_id_fkey" FOREIGN KEY ("buyer_id") REFERENCES "accounts"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE "orders" ADD COLUMN "seller_id" UUID NOT NULL;
ALTER TABLE "orders" ADD CONSTRAINT "orders_seller_id_fkey" FOREIGN KEY ("seller_id") REFERENCES "accounts"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
The next part is where I am finding it tricky. I want to be able to add many products to the order, via an order_products
table which would look like this --
CREATE TABLE order_products
(
id uuid default uuid_generate_v4() primary key,
created_at timestamp default now() not null,
updated_at timestamp default now() not null
);
ALTER TABLE "order_products" ADD COLUMN "order_id" UUID NOT NULL;
ALTER TABLE "order_products" ADD CONSTRAINT "order_products_order_id_fkey" FOREIGN KEY ("order_id") REFERENCES "orders"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE "order_products" ADD COLUMN "product_id" UUID NOT NULL;
ALTER TABLE "order_products" ADD CONSTRAINT "order_products_product_id_fkey" FOREIGN KEY ("product_id") REFERENCES "products"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
However, I want to make the order_products / products for the order record required, and eventually I will create constraints or policies around making sure that the product belongs to the seller/account within the order. How would I go about setting up the requirement of the order_products, or products for the order when creating the order record, specifically with the js client?
I imagine it looking something like this ->
client.from("orders").insert({buyer_id: buyer.id, seller_id: seller.id, order_products([{product_id: productOne.id}, {product_id: productTwo.id}])
, but this obv doesn't work, but something Im after?
Any help on this would be appreciated, and I'm also all ears for any suggestions on a better schema what I'm after.
Thanks!shantanubharadwaj
11/08/2022, 6:31 PMZaDeR47
11/08/2022, 7:32 PMsql
create table posts (
id uuid primary key default uuid_generate_v4() not null,
user_id uuid references auth.users (id) not null,
created_at timestamp with time zone default now() not null,
path ltree not null
);
On inserts to this table, the path
field is set to root
for original posts. All comments then append '.<parent's uuid>'
for their path values.
My function then looks like:
sql
create function get_single_post_with_comments(post_id uuid)
returns table (
id uuid,
-- depth int, <== not sure how to get... could determine from path in frontend
path ltree,
)
language plpgsql
as $$
begin
return query
select posts.id, posts.path
from posts
where posts.path <@ post_id
-- order by p.created_at desc <== need depth-first ordering here....
end;$$
Any ideas on how to get order properly?Dallas
11/09/2022, 7:18 PMAngelo
11/10/2022, 12:54 PMcreateServerSupabaseClient
inside a Vercel Edge function, but it's not working.
I think that {req, res}
values are different inside Edge Runtime, does anyone know a "manual" way to get it authenticated with session cookie?bingbong
11/10/2022, 8:26 PMjkohlin
11/10/2022, 8:28 PM{{ .ConfirmationURL }}
to something different than my root URL? I'd like to change it for testing on localhost.eyk
11/10/2022, 8:55 PMarcavid
11/11/2022, 6:39 AMDaLink
11/11/2022, 9:51 AMTARS
11/11/2022, 10:22 AMCREATE POLICY "policy_name"
ON public.hosts
FOR INSERT USING (
true
);
dalxds
11/11/2022, 10:39 AMuseUser()
hook from the react auth helpers.
So, I use the user to check if a user exists and then go with user ? <AccountMenu> : <SignInButton>
The problem is that the page flashes instantly with the sign in button before showing the <AccountMenu>
component.
Also, when changes between pages that use the same page layout the state doesn't persist and the flashing happens on every page.
How would be the way to go about it without getting the flashing?
Also, if I wanted to bring in some user data as well (name, avatar) what would be the way to do it and not request it for every page change?
Thanks