Shawn Conecone
02/08/2023, 10:52 AMasync function getTemplateImage() {
return await Image.decode(await Deno.readFile("./SKDN-template.jpeg"));
}
with the SDKN-template.jpeg
located on the same level as this script. When I tried invoking this after deployment, I got this error
Error: file system access error (code 42), id:d5072e47-1328-4d9d-b00a-0813f58c11b4
at async Object.readFile (deno:deploy/js/02_fs.js:55:12)
at async getTemplateImage (file:///src/createPdf.ts:14:31)
at async createReportPngs (file:///src/createPdf.ts:103:25)
at async Server.<anonymous> (file:///src/index.ts:11:23)
at async Server.#respond (https://deno.land/std@0.168.0/http/server.ts:221:24)
I'm aware that deno needs explicit permission to read/write to system (https://deno.land/manual@v1.29.1/basics/permissions) but not sure how to allow read in the edge.
Any suggestions? Thanks!bkyerv
02/08/2023, 1:21 PMauthor (that has id and name columns)
and news (that has title and author_id which is a foreign key pointing to the id in the author table
. How do I structure the query so that it returns title
and author of the title
? I tried from('news').select('title', 'author('name')).eq('news.author_id', 'author.id')
. In sql my query would look like select title, name from news inner join author on news.author_id=author.id
algads
02/08/2023, 2:18 PMKjell
02/08/2023, 2:55 PMMonimolimnion
02/08/2023, 2:59 PMRJSTrevor
02/08/2023, 3:48 PMKenneth J Hughes
02/08/2023, 4:18 PMadam21xc
02/08/2023, 4:38 PMJim
02/08/2023, 4:44 PMlocations
table to only allow users who match an "ADMIN" role from their role table to read it, which looks like this:
sql
(
EXISTS
(
SELECT 1
FROM roles r
WHERE (
(r.id = auth.uid())
AND
(r.role = 'ADMIN'::text)
)
)
)
For some reason though it seems to be blocking access as a user. What can I do to debug this? Again pretty new to SQL so it may be something obvious. Thanks!turner
02/08/2023, 4:46 PMsecret_column
in both tables).
sql
CREATE TABLE table_name1 (
id_1 uuid PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
key_id_1 uuid NOT NULL REFERENCES pgsodium.key(id) DEFAULT (pgsodium.create_key()).id,
nonce_1 bytea NOT NULL DEFAULT pgsodium.crypto_aead_det_noncegen(),
secret_column_1 text NOT NULL DEFAULT 'undefined'::text
);
CREATE TABLE table_name2 (
id_2 uuid PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
key_id_2 uuid NOT NULL REFERENCES pgsodium.key(id) DEFAULT (pgsodium.create_key()).id,
nonce_2 bytea NOT NULL DEFAULT pgsodium.crypto_aead_det_noncegen(),
secret_column_2 text NOT NULL DEFAULT 'undefined'::text
);
sql
SECURITY LABEL FOR pgsodium
ON COLUMN table_name1.secret_column_1
IS 'ENCRYPT WITH KEY COLUMN key_id_1 NONCE nonce_1 ASSOCIATED id_1';
SECURITY LABEL FOR pgsodium
ON COLUMN table_name2.secret_column_2
IS 'ENCRYPT WITH KEY COLUMN key_id_2 NONCE nonce_2 ASSOCIATED id_2';
I am able to set the security labels for each table separately, but If I want to add both, it fails, giving me the error:
sql
Failed to run sql query: must be owner of relation table_name1
I am new to this topic and looked up every source I can find online, but none could solve my problem.
I really appreciate your help!
Thank you in advance
Tim π
I also opened an issue in pgsodium and will update if once I find a solution: https://github.com/michelp/pgsodium/issues/73InASunshineState
02/08/2023, 4:55 PMDisamDev
02/08/2023, 5:22 PMjoshuabaker
02/08/2023, 5:48 PM/rest/v1/admin/users
endpoints referenced for createUser
, updateUserById
, etc. donβt seem to work for some reason (trying in Postmark). The responses are always empty (i.e. {}
).
Itβs quite frustrating that the documentation is so thin for the REST API. Are there plans to wind this down?
What am I missing here?Hank Stark
02/08/2023, 6:20 PMHugos
02/08/2023, 6:47 PMjcurbelo
02/08/2023, 6:53 PMUncaught TypeError: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
at Module.convertChangeData (transformers.js?0598:48:1)
at RealtimeChannel._getPayloadRecords (RealtimeChannel.js?153b:446:27)
at eval (RealtimeChannel.js?153b:332:68)
at Array.map (<anonymous>)
at RealtimeChannel._trigger (RealtimeChannel.js?153b:319:14)
at eval (RealtimeClient.js?f065:290:1)
at Array.forEach (<anonymous>)
at eval (RealtimeClient.js?f065:290:1)
at Serializer.decode (serializer.js?d74c:12:1)
at RealtimeClient._onConnMessage (RealtimeClient.js?f065:281:1)
at conn.onmessage (RealtimeClient.js?f065:102:1)
while listening to realtime events, this is a snippet of my code (react):
typescript
supabase.channel('apps-db-changes')
.on(
REALTIME_LISTEN_TYPES.POSTGRES_CHANGES,
{
event: REALTIME_POSTGRES_CHANGES_LISTEN_EVENT.ALL,
schema: 'public',
table: 'App',
},
() => fetchApps()
)
.on(
REALTIME_LISTEN_TYPES.POSTGRES_CHANGES,
{
event: REALTIME_POSTGRES_CHANGES_LISTEN_EVENT.ALL,
schema: 'public',
table: 'Installations',
},
() => fetchApps()
)
.subscribe()
it works fine with insertions and updates, but with deletes it gives me the error, I also checked ws messages:Lukas V
02/08/2023, 6:53 PMproducts
table types looks like:
products: {
Row: {
active: boolean | null;
created_at: string | null;
created_by: string | null;
default_price: string | null;
As you can see default_price
type is string id that points to another table.
Now when I do joins whilst querying data:
let {
data: products,
error,
count
} = await supabase
.from('products')
.select('*, default_price (*), offer_price_id (*)')
default_price
is no longer a string, but the price object, so what is the best way to handle this with typescript?
Should I create new type and simply cast it with as
return type:
return products as ProductsWithPricesCombinedType;
or is there another better method to do this?DisamDev
02/08/2023, 8:45 PMconst { data: { user } } = supabase.auth.getUser()
to use it later in the code but I can't put the async to the path function because it gives error, and if I make a function with the await/async inside I can't export it outside to use it, how can I do it?martinbot
02/08/2023, 8:55 PMPythonic
02/08/2023, 9:20 PMsql
select
coalesce(
nullif(current_setting('request.jwt.claim.role', true), ''),
(nullif(current_setting('request.jwt.claims', true), '')::jsonb ->> 'role')
)::text
I'm pretty sure this should be working as intended, however I'm getting a strange error after manually giving myself the role supabase_admin and making a request with the JWT that includes the role
Uncaught (in promise) Error: permission denied to set role "supabase_admin"
Anyone know what this means and how to avoid it?TheBuilderJR
02/08/2023, 9:31 PMJennn
02/08/2023, 9:32 PMRequestEvent
argument which is not compatible with ServerLoadEvent
that getServerSession(event)
expects.
--
In SvelteKit, you can send HTTP Requests to any API routes you define as +server.ts
files (as opposed to the usual +page.server.ts
.
In the docs, the sveltekit-auth-helpers
provide a getServerSession(event)
that takes in a ServerLoadEvent
. But in contrast, API routes take in a RequestEvent
type (https://kit.svelte.dev/docs/types#public-types-requestevent). Is there a way around this?amankishore
02/08/2023, 10:04 PMcreate extension vector;
I get this error:
Failed to run sql query: could not open extension control file "/var/lib/postgresql/extension/vector.control": No such file or directory
Amor Fati
02/08/2023, 11:25 PMbaddoh99
02/09/2023, 12:22 AMjavascript
useEffect(() => {
const eventLobbyChannel = supabase.channel(
`event-${event.event_id}-players`,
{
config: {
presence: {
key: user.id,
},
},
}
);
eventLobbyChannel.on('presence', { event: 'sync' }, () => {
const state = eventLobbyChannel.presenceState();
console.log(`Online users: `, Object.keys(state).length);
});
eventLobbyChannel.on('presence', { event: 'join' }, (newPlayer) => {
console.log(`New player: `, newPlayer);
});
eventLobbyChannel.on('presence', { event: 'leave' }, (oldPlayer) => {
console.log(`Player left: `, oldPlayer);
});
eventLobbyChannel.subscribe(async (status) => {
if (status === 'SUBSCRIBED') {
const trackUserId = await eventLobbyChannel.track({ userId: user.id });
console.log('Tracked : ', trackUserId);
}
});
return () => {
supabase.removeChannel(`event-${event.event_id}-players`);
};
}, []);
what might i be doing wrong?yayza_
02/09/2023, 12:39 AMjs
const { data: attributes, error } = await locals.supabase
.from("attributes")
.select("*, categories:category_attributes(categories(id, name))");
Response:
{
"id": 1,
"name": "Flavor",
"categories": [
{
"categories": {
"id": 26,
"name": "Candy"
}
},
{
"categories": {
"id": 27,
"name": "Beverages"
}
}
]
}
Is there a cleaner way that would get me the response like :
{
"id": 1,
"name": "Flavor",
"categories": [
{
"id": 26,
"name": "Candy"
},
"id": 27,
"name": "Beverages"
}
]
}
I currently have 3 tables, categories
, attributes
, and category_attributes
, which is just a many to many relationship between those two (thinking I should change this)Holland
02/09/2023, 1:20 AM<Auth
redirectTo='http://localhost:3000/home'
supabaseClient={supabase}
providers={['google']}
appearance={{ theme: ThemeSupa }}
/>
I want that to redirect to /home. But on a successful signin that returns an instance of a user, no redirect happens. How do I fix this?elliott
02/09/2023, 1:45 AMalana
02/09/2023, 2:01 AM<div className="row">
<Auth
supabaseClient={supabase}
appearance={{
theme: ThemeSupa,
variables: {
default: {
colors: {
brand: "#f2acb9",
brandAccent: "#f2acb9",
},
},
},
}}
providers={["google"]}
/>
</div>
Decaf Coffee
02/09/2023, 2:39 AMsupabase.rpc('function')
call similar to RLS?
Maybe I'm misunderstanding, but if a Postgres function is marked as Security Definer
, wouldn't any user calling the function via rpc()
effectively gain service role level access?