Finn
04/18/2022, 12:06 PMFinn
04/18/2022, 12:30 PMevanw
04/18/2022, 1:01 PMconversations
with column participants
of type JSONB (originally JSON but I think it needs to be JSONB) where the structure is something like:
[
"Emily",
"Renee",
"Martina"
]
I'm trying to return an array of all conversations
where participants
includes the current user, e.g. "Emily".
This is what I've tried, but I'm certain this is wrong:
let { data, error, status } = await supabase
.from('conversations')
.select('id, name, participants')
.contains('participants', ['Emily']);
Any pointers? Or should my data be structured differently? (Future state, participants
might be more like [ { name: 'Emily', id: 123 } ]
but for right now I'm just trying to sorta learn the basics
The error I'm getting with this is "invalid input syntax for type json"NinjaNuur
04/18/2022, 1:11 PMdrop trigger if exists on_auth_user_created on auth.users;
create trigger on_auth_user_created
after insert
on auth.users
for each row
execute procedure public.handle_new_user();
Function
create or replace function public.handle_new_user()
returns trigger
language plpgsql
security definer set search_path = public
as
$$
begin
if new.phone is null then
insert into public.company_user (id, email, first_name, last_name)
values (new.id, new.email, new.raw_user_meta_data ->> 'first_name', new.raw_user_meta_data ->> 'last_name');
return new;
else
insert into public.personal_user (id, phone)
values (new.id, new.phone);
return new;
end if;
end;
$$;
Any help would be appreciatedSimey
04/18/2022, 1:18 PMlists
with a user_id
column. I keep trying to add a rule for auth.uid() = user_id
, it adds successfully. However, it doesn't work. The first thing that looks funny is that on the policies view it shows as "ALL Users can only see their own lists `(uid() = user_id)`" with uid()
on its own instead of auth.uid()
. Furthermore when I then try to access rows it returns nothing.Simey
04/18/2022, 1:21 PMfeLiruc
04/18/2022, 1:57 PMnicedaynot
04/18/2022, 7:49 PMmeera_datey
04/19/2022, 1:45 AMachilles
04/19/2022, 2:40 AMSteve
04/19/2022, 3:21 AMtext
row in the db?JonWasTaken
04/19/2022, 3:55 AMdb error: ERROR: malformed array literal: ""
Here's the SQL, anyone know why it would be causing this error?
ALTER TABLE props ADD COLUMN textSearch tsvector GENERATED ALWAYS AS (
setweight(to_tsvector('english', coalesce(name, "")), "A") ||
setweight(to_tsvector('english', coalesce(terms,"")), "B")
) STORED;
CREATE INDEX props_textsearch_idx ON props USING GIN (textSearch);
Needle
04/19/2022, 4:07 AM/title
command!
We have solved your problem?
Click the button below to archive it.Tim Nirmal
04/19/2022, 4:51 AMjoshcowan25
04/19/2022, 5:13 AMjoshcowan25
04/19/2022, 5:15 AMemjay
04/19/2022, 7:45 AMLudvig
04/19/2022, 7:54 AMenti
04/19/2022, 10:04 AMquestions
table with just a row of different questions. Each question can have different answers. Those are in a table answers
, containing a foreign key question_id
. I use an API call to get the structure I want :
js
let { data: questions, error } = await supabase
.from('questions')
.select(`
question,
answers(
answer
)
`)
json
[
{
"question": "question one",
"answers": [
{
"answer": "answer one for question one"
},
{
"answer": "answer two for question one"
}
]
},
{
"question": "question two",
"answers": [
{
"answer": "answer one for question two"
},
{
"answer": "answer two for question two"
}
]
}
]
But, for security reasons, I want to get the same result using a function and a RPC call. Unfortunately, I can't figure it out on my own. Is there a way to do it ?Needle
04/19/2022, 10:12 AM/title
command!
We have solved your problem?
Click the button below to archive it.Evaldas_B
04/19/2022, 10:17 AMbatuhanbilginn
04/19/2022, 10:33 AMNeedle
04/19/2022, 2:07 PM/title
command!
We have solved your problem?
Click the button below to archive it.pckimlong
04/19/2022, 3:19 PMInfrapuna
04/19/2022, 3:44 PMxenocythe
04/19/2022, 5:00 PMummahusla
04/19/2022, 8:17 PMngrok
and localtunnel
while doing local development.
Any ideas on how to debug it? I've tried to google, but haven't found the proper answer
https://app.supabase.io/project/.../database/api-logs?te=&ts=eoin
04/19/2022, 8:40 PMuser.uid
is in a players
array can access a /game/game.uuid
route. It's working, but the "blocked" route is firing a 304
request to /api/game/null
(guessing once RLS is hit) and then throwing code:22P02, message; invalid input syntax for type uuid: \\\"null\\\"
. It then tries to render the component with no data and fails.
Ideal state is that I can handle this more gracefully, add that the user.uid
doesn't have access to this particular route to state and render an input field for them to enter a code which—if correct—would add their user.uid
to the original players
array, therefore meeting the criteria of the policy and providing access.
Does anyone know how to better handle this redirect to /api/game/null
and use it to control state rather than crash out?Prodigy7kX
04/19/2022, 9:05 PMts
async function deleteOneAccount(id: string) {
const { data: account, error } = await supabase
.from<Account>('accounts')
.delete()
.match({ id })
.throwOnError();
return { account, error };
}
The query is executed just fine but always throws back a warning:
json
{
"details": "Results contain 0 rows, application/vnd.pgrst.object+json requires 1 row",
"message": "JSON object requested, multiple (or no) rows returned",
}
Can anyone explain why it does happen?huga
04/19/2022, 9:12 PM