Thoth Trismegistus
09/12/2022, 4:28 PMgerry
09/12/2022, 4:32 PMpvtctrlalt
09/12/2022, 4:51 PMmohammed-io
09/12/2022, 6:17 PMncbphi001
09/12/2022, 7:59 PMflixoflax
09/12/2022, 9:01 PMUncaught TypeError: authListener.unsubscribe is not a function.
Can somebody help me with this? Thank you very much. I am using typescript btw.pasha_dee
09/12/2022, 11:32 PMmaglev
09/13/2022, 1:46 AMshrey
09/13/2022, 3:15 AMSpartan
09/13/2022, 4:48 AMinsert_document_contributor_by_update_documents
which is triggered, as the function states, by an update in the documents
table. This is the current version of the function.
plpgsql
begin
insert into public.document_contributor(document_id, contributor)
values(new.id, new.created_by);
return new;
end
But I want to check if the document_contributor
table has an existing record with the match of document_id
and contributor
. Fyi, the document_contributor
table is a join table that consists of only two columns stated above, document_id
and contributor
, and uses both of them as a composite primary key.
How do I add a condition and modify the function to my needs?LeoSonnekus
09/13/2022, 5:35 AMnickreed
09/13/2022, 6:14 AMmy_function(new)
but get an error that "new is not a column". my_function(*)
also did not work.
My function is pretty simple (docs is the name of the table):
create or replace function public.my_function(docs)
returns boolean as $$
begin
return true;
end;
$$ language plpgsql security definer;
lewisd
09/13/2022, 7:21 AMlistings
, listingLikes
and a userData
table.
I have the very standard setup of when a user likes a listing, a listingLikes
row is created connecting the listing
and the userData
. listingLikes
just contains a listingId
and a userId
Using supabase-js
how can i say "Go find all the listingLikes
that has this listing
as the listingId
, then get all the userIds
and select them from the userData
table?lewisd
09/13/2022, 9:12 AMconst { data } = await supabase
.from("listings")
.select(`*, sellerData:sellerId(*), listingLikes(userData(*))`);
listingLikes
returns an array like so:
[{userData: {...data}},{userData: {...data}}]
whereas I would like to just have:
[{...data}, {...data}]
garyaustin
09/13/2022, 1:28 PMRían
09/13/2022, 10:39 AMjs
const { data } = await supabase
.from("submissions")
.select("content, created_at")
.gt("created_at", "current_timestamp - interval '1 hour'")
.eq("content", post);
lewisd
09/13/2022, 10:57 AMuserDataSubscribe = supabase.from(`'userData:id=eq.${currentUser.id}'`)
.on("*", (payload) => {
console.log("Change received!", payload);
})
.subscribe();
It never fires. I've attached my userData
tableShecky
09/13/2022, 11:31 AMMrGandalfAndhi
09/13/2022, 11:36 AM<column type> | undefined
. When using undefined as a value in an update to set the column to null it is omitted and thus not updated at all. I am able to set it to null by explicitly setting the value in the update object to null, but this causes typescript to complain about mismatched types.
What's the suggested way of handling updates to null while using typescript with the generated definitions?DesertRodent
09/13/2022, 1:20 PM- Muscle_Regions
- Muscle_Region_Muscle_Parts (M:M)
- Muscle_Parts
- Muscle_Parts_Mucles (M:M)
- Muscles
From a region level i am able to list all the muscle parts with the following query:
let { data: muscle_regions, error } = await supabase
.from<MuscleRegion>('muscle_regions')
.select('*, muscle_parts (*)')
but when i try to do the same thing on the muscle_part level i don't get any results...
If I try this query it doesn't error but it doesn't show me any muscle results:
let { data: muscle_regions, error } = await supabase
.from<MuscleRegion>('muscle_regions')
.select('*, muscle_parts (*, muscles(*))')
I have created composite keys and assigned them to the correct tables its just not rendering
Any clues?garyaustin
09/13/2022, 4:45 PMlewisd
09/13/2022, 2:39 PMuserData
called points
. When a user gives another user points, this amount increments by 100.
I would then have a field called pointGivers
where I would store the givers user data + how many points they have given in total.
I'm trying not to go back to my noSQL ways so how would you best do this?
Would the most sensible thing be to join users and their point givers via a table. In that table we'll store the givers data and the amount of points given and I'll just query that, or would you more SQL experienced guys also have a totalPoints
field stored on each users row.kaaloo
09/13/2022, 4:06 PMbrassknucklenerd
09/13/2022, 4:39 PMmejiasdev
09/13/2022, 4:39 PMnickreed
09/13/2022, 5:33 PMselect content::json->>'allowed'
from http_get('https://jsonplaceholder.typicode.com/todos/1');
but http_post fails:
select content::json->>'allowed'
from http_post('https://jsonplaceholder.typicode.com/todos/1',
jsonb_build_object('test', 'test')
);
with errors:
hint: "No function matches the given name and argument types. You might need to add explicit type casts."
message: "function http_post(unknown, jsonb) does not exist"
I don't understand why/how casting is failing, and why get works but not post?anderjaska
09/13/2022, 5:40 PMALTER TABLE "User" ADD FOREIGN KEY ("id") REFERENCES "auth"."users"("id");
results in:
Failed to run sql query: foreign key constraint "User_id_fkey" cannot be implemented
I think the error may be on prisma, is this something that cannot be done?
The goal here is that I want to delete a db entry when an auth user is deleted -> perhaps a trigger is more appropriate?
Thanks!Jakob
09/13/2022, 7:07 PMDevThoughts
09/13/2022, 6:16 PMBoogersLLC
09/13/2022, 6:45 PMBlogs
User A
creates Blog X
User A
invites User B
to able to SELECT/UPDATE to Blog X
and invites User C
to only be able to SELECT from Blog X
---
Is this something that I would handle with RLS? Does anyone have any examples that could get me going in a direction? I've read through [auth policies](https://supabase.com/docs/learn/auth-deep-dive/auth-policies) but most examples like this one seem to be somewhat static (the email @blizzard
isn't something one user could assign/share to another)
I'm guessing I may need to add a new role? But I'm not sure how to do that on a many-to-many relationship. i.e. Many users will have different access to many blogs.
Also, to reiterate, Blogs is just a contrived example. Imagine this scenario with anything. Chat rooms, Trello cards, Google Docs, etc...