SUPABASE: unable to select multiple columns from a single table
Answered
American Crocodile posted this in #help-forum
American CrocodileOP
So i'm new to supabase. i got a table with a few rows in it.
when i try to select everything inside that table it works perfectly like:
and the console log works perfectly:
but when i try to do a specific multi slection like
it only lets me see the first selected column as you can see in this console log:
i'm sure my RLS is good cuz i only have one RLS policy for reads that makes selection available for all users, i'm also sure about my column names and i dont know what i'm doing wrong.
when i try to select everything inside that table it works perfectly like:
const supabase = createServerComponentClient({ cookies });
let { data: data, error } = await supabase
.from("projects")
.select("*");
if (error) {
console.log(error);
}
console.log({ data });and the console log works perfectly:
- wait compiling...
- event compiled client and server successfully in 771 ms (1133 modules)
{
data: [
{
id: 1,
user_id: '7ceacb8d-9031-4584-a78a-bb3eb163f57d',
table_id: '5fecfa6c-d2e2-455f-bd6e-b17b5da4cb86',
title: 'firstTitle'
},
{
id: 2,
user_id: '7ceacb8d-9031-4584-a78a-bb3eb163f57d',
table_id: '397a5c4e-b5c3-4382-8d0b-67c4489e3352',
title: 'SecondTitle'
},
{
id: 3,
user_id: '7ceacb8d-9031-4584-a78a-bb3eb163f57d',
table_id: '29444ae4-72f2-4b38-9bde-63f7147aa7d3',
title: 'ThirdTitle'
}
]
}but when i try to do a specific multi slection like
let { data: data, error } = await supabase
.from("projects")
.select("title", "id");
if (error) {
console.log(error);
}
console.log({ data });it only lets me see the first selected column as you can see in this console log:
- wait compiling...
- event compiled client and server successfully in 423 ms (1133 modules)
{
data: [
{ title: 'firstTitle' },
{ title: 'SecondTitle' },
{ title: 'ThirdTitle' }
]
}i'm sure my RLS is good cuz i only have one RLS policy for reads that makes selection available for all users, i'm also sure about my column names and i dont know what i'm doing wrong.
Answered by American Crocodile
for future onlookers this is how you select multiple columns correctly
.select("title, id");2 Replies
American CrocodileOP
i found out why and it was a simple syntax typo
American CrocodileOP
for future onlookers this is how you select multiple columns correctly
.select("title, id");Answer