jon
11/01/2021, 5:16 PMjon
11/01/2021, 5:18 PMMike92988
11/01/2021, 11:15 PMlarryM
11/03/2021, 3:24 PMSteve
11/03/2021, 4:26 PMthe.watcher
11/04/2021, 6:59 AMthe.watcher
11/04/2021, 9:16 AMsilentworks
11/04/2021, 10:12 AMkresimirgalic
11/04/2021, 8:23 PMhoesmean
11/04/2021, 9:02 PMPragy
11/05/2021, 9:55 AMsilentworks
11/05/2021, 10:29 AMunix17
11/06/2021, 10:27 AMXzeta
11/06/2021, 1:24 PMuseEffect(() => {
setSession(supabase.auth.session());
if (supabase.auth.session()){
getProfile();
//setProfile
}
supabase.auth.onAuthStateChange((_event, session) => {
setSession(session);
});
}, []);
egnus
11/06/2021, 7:11 PMusers
, projects
, roles
and projectMembers
with Primary keys user_id, project_id
and a single role_id
per user/project (not primary).
I want to know if a given user is capable of reading a random table if we know the project owner of the table and the user itself. So i use this:
javascript
const { data, error } = await supabase
.from("users")
.select("name, projects(name, role:roles(name))")
.eq("id", 1) // id of the user
.eq("projects.id", 2) // id of the project
.single();
The problem is that, even if i fix the FK of the project to 2 I still get an array for projects, and even if only one role can be assigned, I also get and array of objects. Is it there any way i can make foreign tables to be single if I know they should be only one???
This is what I get for example from the previous project:
json
{
name: 'John',
projects: [
{ name: 'ACME', role: [ { name: 'project_admin' } ] }
]
}
Also, another weird thing with the API, If i filter a foreign key and nothing is found, I still get all the table with []
in the foreign key. How can I remove entries that are empty or not found in foreign tables from the main table. Example:
javascript
const { data, error } = await supabase
.from("users")
.select("name, projects(name)")
.eq("projects.id", 9999) // nobody is asigned to this project.
instead of getting []
I get all the users but with empty foreign key like this:
json
[
{
name: 'John',
projects: []
},
{
name: 'Mike',
projects: []
},
// and all the entire list of users. When nothing should actually be returned.
]
I don't undertand but I think this issues are unavoidable in the Javascript library, aren't they?Vinzent
11/06/2021, 7:13 PMSteve
11/06/2021, 9:48 PMunix17
11/06/2021, 10:59 PMlarryM
11/07/2021, 1:00 AMgaryaustin
11/07/2021, 1:08 AMlarryM
11/07/2021, 1:09 AMFerran
11/07/2021, 7:00 AMScott P
11/07/2021, 5:17 PMmagicbyt3
11/07/2021, 7:52 PMgaryaustin
11/07/2021, 8:15 PMmagicbyt3
11/07/2021, 8:20 PMMike92988
11/08/2021, 8:28 AMegnus
11/08/2021, 8:46 AMyourfriend
11/08/2021, 6:32 PMyourfriend
11/08/2021, 6:37 PM