s0lo1
09/11/2022, 2:04 AMKickSquare
09/11/2022, 3:07 AMNanoBit
09/11/2022, 9:23 AMJAGUAR
09/11/2022, 11:25 AMavatars
to allow users to INSERT and UPDATE a file named {id}.png
where {id}
is their user id.
Example 44451f44-bdc7-43ba-a6c2-f06495c99380.png
should be able to be updated and inserted by a user with id 44451f44-bdc7-43ba-a6c2-f06495c99380
.eunjae
09/11/2022, 12:56 PMparticipations
tables. This participations
has both room_id
and user_id
. When a user enters a room, a new row is added. You get the idea, right?
I have this function:
create or replace function is_participating(param_room_id uuid)
returns boolean as $$
select exists
(
select 1
from participations
where room_id = param_room_id
and user_id = auth.uid()
and (role = 'admin' or role = 'user')
and status = 'granted'
);
$$ language sql;
But when I use this function for
create policy "Can view participations of rooms where they already participate." on participations for select using (is_participating(room_id));
it falls into infinite recursive loop. What's the smart way to deal with this?d33pu
09/11/2022, 2:42 PMThoth Trismegistus
09/11/2022, 3:40 PMaaron
09/11/2022, 4:38 PMconst { data, error } = await supabase.from('countries').select(`
name,
country_capitals (
city (
name
)
`)
However, the data returned is:
{
"name": "USA",
"country_capitals": [
{
"city": {
"name": "Chicago"
}
},
{
"city": {
"name": "New York"
}
}
]
}
Is there a way to just return the data directly without the join table nesting? Like:
"name": "USA",
"capitals": ["Chicago", "New York"
etc... I know I can do the transformation on the frontend, but seems cleaner if there is just a better way of requesting the data from the SDKJordanStafford
09/11/2022, 6:10 PMProtoFeather
09/11/2022, 6:10 PMhttps://i.imgur.com/IrFoSYp.png▾
FunHellion
09/11/2022, 7:42 PMNinjaa
09/11/2022, 7:44 PMShawn Conecone
09/11/2022, 10:23 PMdoctor_eval
09/11/2022, 11:27 PMvjoohov
09/12/2022, 2:20 AMjamalam
09/12/2022, 6:52 AMth0rin0
09/12/2022, 7:58 AMarechsteiner
09/12/2022, 10:46 AMawait supabasePublic.auth.update({ password: data.password })
on the front end. I noticed it is no way necessary to provide the old password on the api.
Is there any setting to require this? I couldn't find anything. This seems like a common security feature.MrSARS
09/12/2022, 11:34 AMselect categories.id, categories.category, categories.image_name, count(item.category_id)
from categories
left join item
on categories.id = item.category_id
group by item.category_id, categories.category , categories.image_name, categories.id
order by categories.id asc
wei
09/12/2022, 12:08 PMavatars/<user_id>
with RLS select
public read for anons, insert
and update
for authenticated if
sql
((bucket_id = 'avatars'::text) AND ((uid())::text = storage.filename(name)))
But update doesn't work. Upload works.
TS code for upload (create) only is
ts
await supabase.storage
.from('avatars')
.upload(user.id, value.files[0]);
Update with upsert via upload method option returns
json
{
"statusCode": "42501",
"error": "",
"message": "new row violates row-level security policy for table \"objects\""
}
And update with or without upsert returns 404
Thank you!pek
09/12/2022, 12:41 PMWebSocket connection to 'wss://<xxxx>.supabase.co/realtime/v1/websocket?apikey=<yyyyyy>=1.0.0' failed:
W3CWebSocket @ browser.js?eccf:25
connect @ RealtimeClient.js?6b6d:104
eval @ RealtimeClient.js?6b6d:94
fulfilled @ RealtimeClient.js?6b6d:4
Lukas V
09/12/2022, 1:18 PMMiguel Espinoza
09/12/2022, 1:56 PMconst supabase = createClient(supabaseUrl, supabaseKey, {
autoRefreshToken: true,
persistSession: true,
localStorage: browserStorageInterface,
});
I'm depending on supabase to handle token refresh, but this conflicts with subsequent request to the database.
While the token refreshes, a request to the database occurs, but the token is invalidated on request flight. One of these requests returns a 406 (which I believe is the wrong status code).
So two things:
- Is there a solution to wait for this._callRefreshToken()
to complete before making subsequent request?
- If token is invalid, shouldn't the status code be 401 instead?
https://github.com/supabase/supabase/discussions/2284
It seems I'm getting a 406 because I'm using .single()
. I still think an invalid token should override the error messageAhmad Swultra
09/12/2022, 2:37 PMselect status
from
http_post(
'https://website.com/api/users/1/',
'{"status":"active"}',
'application/json'
)
OberstKlinck
09/12/2022, 2:44 PMparents
and children
. One parent can have many children and each child is assigned to a parent through a parent_id
column.
I created a Database Webhook that triggers an HTTP request to a Supabase Edge Function whenever a DELETE query is run on parents
. Through a cascading delete, this delete query also deletes all children of that parent.
In my Supabase Edge Function though, I only see the now deleted parent
row as the payload.
Is there a way for me to supply not just the parent
row but also its now-deleted children rows as well? So that the old_record
supplied to my function would look something like this:
{
id: "123",
children: [
{ id: "234" }, { id: "345" }, { id: "456" }
]
}
?loong
09/12/2022, 2:53 PManderjaska
09/12/2022, 3:11 PMSTILLWATER;
09/12/2022, 3:55 PMrlee128
09/12/2022, 4:08 PMDeleted User
09/12/2022, 4:21 PMjavascript
app.get('/api/get-book-by-id/:id', cors(corsOptions), async (req, res) => {
const {data, error} = await supabase
.from('books-express')
.select('*')
.match({id: req.params.id})
console.log(error)
console.log(data)
if (error)
res
.status(404)
.send({message: `ERROR CODE: ${error.code}: ${error.message}`})
// res.send(data)
})
I can return data
with the correct book ID if present but if not I just get an empty array...but errror is null
surely this should be throwing an error saying no id of x is present