logemann
01/30/2023, 12:39 PMHypps
01/30/2023, 12:42 PMeloahsam
01/30/2023, 1:12 PMnimo
01/30/2023, 4:21 PMCREATE TABLE project (
id uuid primary key,
project_name text,
...
);
CREATE TABLE interview (
id uuid primary key,
notes text,
project_id uuid
....,
CONSTRAINT fk_project_id
FOREIGN KEY(project_id)
REFERENCES project(project_id)
);
The relationship is project HAS MANY interview
.
I'd like the interview to have a UUID primary key so you can't "guess" how many interviews have been done. But ideally, it would also be sequential on a PER PROJECT basis. Is there an easy way to set this up?kyds3k
01/30/2023, 5:31 PMphilbookst
01/30/2023, 6:31 PMts
const { supabase } = useOutletContext<Context>();
useEffect(() => {
const jobs = supabase
.from("jobs")
.on("*", (payload) => {
console.info({ payload });
})
.subscribe();
return () => {
supabase.removeSubscription(jobs);
};
}, [supabase]);
but the payload callback doesn't run at all. Doing a simple select works just fine but the subscription doesn't even tho I see a websocket connection being made in the dev tools - which is stuck in a pending state.
I do not have any RLS policies in place if that matters
Thanks for your help!Smardrengr
01/30/2023, 6:33 PMDomcario
01/30/2023, 7:21 PMjs
const [user, setUser] = useState(null)
useEffect(() => {
async function fetchUserInfo() {
const { data: { user } } = await supabase.auth.getUser()
if (user) {
setUser(user)
}
}
fetchUserInfo()
}, [])
while trying to implement useSWR (https://swr.vercel.app/), i can't pass in a promised value like user.id
and the fact it defaults to null makes it a little annoying too. is there a better way for me to retain the output of supabase.auth.getUser
throughout my app instead of calling it on each page.c yan ♡
01/30/2023, 7:23 PMchannel.unsubscribe()
and supabase.removeSubscription(channel)
?MohammadAlian_2004
01/30/2023, 7:32 PMJoshTheNerd
01/30/2023, 8:01 PMGreenArruh
01/30/2023, 8:02 PM1chbinamin
01/30/2023, 8:19 PMdamian_w
01/30/2023, 8:51 PMif(error){
handleError(error)
}
But i looking for some global solution.
For now i use globally:KrishenK 君主
01/30/2023, 9:13 PMComma-separated UNIQUE column(s) to specify how duplicate rows are determined. Two rows are duplicates if all the 'onConflict' columns are equal.
I have got the error : (CODE 42P10)
there is no unique or exclusion constraint matching the ON CONFLICT specification
I don't know what is wrong in my configuration. 😰
My tables :
postgresql
create table if not exists rooms (
id uuid default uuid_generate_v4() primary key,
creator uuid references public.users not null default auth.uid(),
created_at timestamp with time zone default timezone('utc'::text, now()) not null
);
create table if not exists songs (
id bigint generated by default as identity primary key,
video_id VARCHAR(50) not null UNIQUE,
user_id uuid references public.users not null default auth.uid(),
room_id uuid references public.rooms on delete cascade not null UNIQUE,
created_at timestamp with time zone default timezone('utc'::text, now()) not null,
voters uuid[]
);
My function :
js
this.auth.supabase.from('songs').upsert({
user_id: this.auth.getCurrentUserId(),
video_id: payload.trackId,
room_id: this.getRoomId(),
voters: [this.auth.getCurrentUserId()],
}, {
onConflict: 'video_id, room_id',
}).then(() => {
console.log('Data sent');
});
PS : I think the problem is with the column room_id
because only with video_id, it works. But I can't figure out. I wish your help 🙏Trevvy
01/30/2023, 10:22 PMakella
01/30/2023, 10:54 PM(video_id,video_URL)
.
I also have a PURCHASES table: (user_id, video_id)
where user_id is a foreign key from auth.
When i load the video-page i do this now:
javascript
const { data } = await supabase
.from('*VIDEOS*')
.select("*")
.eq("video_id", id);
Is there a way to check if current user has access to this particular video_id?
So i imagine, i would create a policy in RLS to check if user can get this content. But i dont have my current SQL query parameters there right? I dont have video_id - to look up my purchases table.
What do you think is the best way to solve this problem? May be RLS is the wrong tool for this case?maglev
01/30/2023, 11:26 PMor
operation like this using the Supabase Client:
`.or(first_name ILIKE '%str%', last_name ILIKE '%str%'
)`
to return results if the string inside %%
is contained in the first_name and/or last_name column.
What would be the correct way of writing this part? Thanks.Holland
01/30/2023, 11:49 PMconst { data, error } = await supabaseClient.auth.signInWithOAuth({
provider: 'google',
})
2. Attempt to get user
const userInfo = await supabaseClient.auth.getUser()
3. Get error message
data: {user: null}
error: AuthApiError: invalid claim: missing sub claim at eval (webpack-internal:///.
name:"AuthApiError"
status: 401
__isAuthError: true
message:"invalid claim: missing sub claim"
stack: "AuthApiError: invalid claim: missing sub claim
at eval (webpack-internal:///./node_modules/@supabase/gotrue-js/dist/module/lib/fetch.js:49:20)"
What I am using I am using Next.js. I installed the following:
@supabase/auth-helpers-nextjs
@supabase/auth-helpers-react
@supabase/auth-ui-react
Note
Logging in and signing up with email and password work fine for me. I call signUp to create a user with email and password and signInWithPassword to log them in with email and password. Calling supabaseClient.auth.getUser() after logging in with email and password returns a user for me.
I am confused on how to actually impliment a signup with google. As I only see the function for signInWithGoogle(). How do I signin and signup with google?ramon
01/31/2023, 12:23 AMchungus
01/31/2023, 1:35 AMsignUp
requires you to attach a password
field.
however, if the desired flow is more
1. enter phone in sign up flow
2. receive OTP
3. verify signup with OTP
4. sign the user in with session/refresh
this looks more like something we need to stitch together ourselves. namely
1. create a user with insert
2. call verifyWitOTP
3. collect and input challenge to receive session
4. delete the user if OTP fails/times out/user quits
however, this seems like a code smell. is there a specific security reason why we can't sign users up after they complete their first OTP challenge?JamesB
01/31/2023, 1:37 AMsql
create policy if not exists "abc" ....
does not seem to work.Jonathan Leung
01/31/2023, 1:58 AMDecaf Coffee
01/31/2023, 2:33 AMAnarki
01/31/2023, 2:48 AMJoshTheNerd
01/31/2023, 3:09 AMline 15
causes the above console errormorgan
01/31/2023, 5:46 AMor()
filter. (match atleast one filter).
However it doesn't seem possible with the use of foreignTable
{ foreignTable: 'cities' }
, since it forces that table within the filter. https://supabase.com/docs/reference/javascript/or
What I want to achieve would look like this:
const { data, error } = await supabase
.from('countries')
.select(`
name,
cities!inner (
name
)
`)
.or('cities.country_id.eq.1,name.eq.china,name.eq.denmark')
This would work just like other inner joins (https://supabase.com/docs/reference/javascript/using-filters)
Maybe we can get rid of need for foreignTable
on the or
filter in future versions? If there's a workaround please let me know.
Thank you ☺️rimraf
01/31/2023, 6:10 AMnlst
01/31/2023, 6:22 AMelliott
01/31/2023, 7:52 AM