brad
12/19/2022, 3:07 PMDevr
12/19/2022, 4:08 PMKirioXX
12/19/2022, 4:12 PMsh
Failed to run sql query: "authenticated" is a reserved role, only superusers can modify it
Is there another way to change the timeout that doesn't require a super user?
Thanks!redwookie
12/19/2022, 5:30 PMRaginKajan
12/19/2022, 5:41 PMSolias
12/19/2022, 5:44 PMvexkiddy
12/19/2022, 6:20 PM+page.server.js
file and gets called when the user visit's a particular url path eg. /explore
(I'm using sveltekit v1 + supabase btw)
import supabaseInit from '$lib/db'
export async function load( event ) {
console.log(event)
const { data, error } = await supabaseInit
.from('drops')
.select(`
*,
collectibles (
*
)
`)
.order('id', { ascending: false })
let drops = data;
for(let i = 0; i < data.length; i++) {
let profileData = await (await fetch(event.url.origin+'/profile/?value='+data[i].address)).json()
drops[i].profileData = profileData
}
return {
drops: drops
};
}
This code goes off and gets a bunch of data from the drops table and returns it. However it blocks the page from rendering until its loaded all the data, including all the images. Some of the images are fairly large, however the browser doens't navigate away from the currently viewed page until all the data from supabase is loaded. Which in this cases takes a fairly long time. What am I doing wrong here ? Ideally i'd like to navigate to the page straight away and then a subset of the data gets loaded in. Either using lazy loading for the images or some kind of loading indicator. Could this be Sveltekit and not Supabase ?? Thanks in advance !wasinwatt
12/19/2022, 6:31 PMbhark
12/19/2022, 7:36 PMusers
and teams
. These are coupled by a join table, with columns like this:
id (primary key)
user_id (primary key)
team_id (primary key)
I can then grab the users teams by doing something like this:
.from('user')
.select('teams!inner (*)')
.eq('id', user.id)
Now, let's say users can be assigned admin privileges per team. The user could be a member of several teams, but only have admin level privileges on one team. I'll call this column is_admin
.
The only reasonable place to store is_admin
, as far as I'm aware, would be in the join table. My table would then look like this:
id (primary key)
user_id (primary key)
team_id (primary key)
is_admin
\- but since I'm not querying the join table directly, I can't access the is_admin
column.
This seems to me like a trivial issue, but I can't seem to find any good solution. Maybe I'm searching on the wrong terms.
Any pointers in the right direction is appreciated!hermesalvesbr
12/19/2022, 8:02 PMKenji | Neon Crisis
12/19/2022, 9:54 PMElfhild
12/19/2022, 10:13 PMWalkerJson
12/19/2022, 10:26 PMVWL Tobias Hassebrock
12/19/2022, 11:35 PMkaori
12/19/2022, 11:37 PMVik
12/20/2022, 12:00 AMlet { error } = await supabase.storage
.from('avatars')
.update('123456/avatar', formData);
if (error) {
console.log(error);
return;
}
Vik
12/20/2022, 1:32 AMif (!result.canceled) {
const imageData = result.assets[0];
const filePath = `${userId}/avatar`;
const photo = {
uri: imageData.uri,
type: imageData.type,
name: imageData.fileName,
};
const formData = new FormData();
formData.append('file', photo);
// Upload or replace existing users avatar
let { error } = await supabase.storage
.from('avatars')
.upload(filePath, formData, {
upsert: true,
});
if (error) {
console.log(error);
showErrorToast('Error', 'Something went wrong.');
return;
}
// Get the URL from the storage bucket
const { data: urlData } = await supabase.storage
.from('avatars')
.createSignedUrl(filePath, 99999999999999999999999999999);
// Update the users public profile with the new avatar URL
const { data: userData } = await supabase
.from('profiles')
.update({ avatar_url: urlData?.signedUrl })
.eq('id', userId);
return userData;
}
rlightner
12/20/2022, 1:39 AMizurugi
12/20/2022, 1:52 AMnick-gorman
12/20/2022, 4:12 AMvikiyo
12/20/2022, 5:23 AMCheesyNeesh
12/20/2022, 5:34 AMelliott
12/20/2022, 5:38 AMApe R Us
12/20/2022, 7:00 AMInASunshineState
12/20/2022, 7:36 AM["blue", "red", "dark purple"]
I can get it to match individual tags great. And I mean GREAT. Blazing fast. Nine (single digit 9) millisecond returns across oodles of rows.
But I'd really like to use the similarity searches of that same column.
Similarity seems to be for pure text columns, but for the life of me I can't seem to get a solution; if I try solutions to cast the column when indexing my plan usually involves something that's a set-returning function (like jsonb_array_elements_text ) or it rejects it if it sees something like "mycolumn->>" or "mycolumn::text"
SELECT tags FROM images WHERE jsonb_array_length(tags) > 0 and tags &@* '["compelte"]
Failed to run sql query: operator does not exist: jsonb &@* unknown
And then if I ever get semi-successful, like trying to break apart the array into independent rows for evaluations:
Failed to run sql query: pgroonga: [similar][text] similar search available only in index scan
Regardless of where or not I have used
SET enable_seqscan = off;
Any good leads I can follow?AliCodes!
12/20/2022, 8:59 AMsql
CREATE PROCEDURE transact(id TEXT, created_at timestamptz, til TEXT, fra TEXT, beskrivelse TEXT, value float8)
LANGUAGE SQL
AS $BODY$
INSERT INTO transaktioner VALUES (id, created_at, til, fra, beskrivelse, value);
UPDATE kunder SET saldo = kunder.saldo - value WHERE id = fra;
UPDATE kunder SET saldo = kunder.saldo + value WHERE id = til;
$BODY$;
```but when I try to call it with the SB JS API: ```ts
interface Transaktion {
id: string,
created_at: string,
fra: string,
til: string,
value: number,
beskrivelse?: string,
}
const transaktionKomplet: Transaktion = generateTransactionSomehow():
console.log(await supabase.rpc("transact", transaktionKomplet));
, it throws the error: ```json
{
error: {
code: 'PGRST202',
details: null,
hint: 'If a new function was created in the database with this name and parameters, try reloading the schema cache.',
message: 'Could not find the public.transact(beskrivelse, created_at, fra, id, til, value) function or the public.transact function with a single unnamed json or jsonb parameter in the schema cache'
},
data: null,
count: null,
status: 404,
statusText: 'Not Found'
}
```Am I missing something about how RPCs work?bent
12/20/2022, 9:04 AMts
import { createClient, SupabaseClient } from "@supabase/supabase-js";
import { PostgrestFilterBuilder } from "@supabase/postgrest-js";
but after updating SvelteKit and Vite it now results in this:
import { PostgrestFilterBuilder } from "@supabase/postgrest-js";
^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Named export 'PostgrestFilterBuilder' not found. The requested module '@supabase/postgrest-js' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from '@supabase/postgrest-js';
const { PostgrestFilterBuilder } = pkg;
And if I comply it claims that there are no default exports :/
I recall always having warnings related to something in that direction, but I could always just ignore them and it would work.nidhin
12/20/2022, 9:26 AMJim
12/20/2022, 9:50 AMSM0RT
12/20/2022, 10:20 AMdart
/// Sign up action that will be performed on
/// click to action button in sign up mode.
Future<String?> onSignup(SignUpData signupData) async {
try {
await supabase.auth.signUp(
email: signupData.email,
password: signupData.password,
data: {'username': signupData.name, 'language': signupData.language},
emailRedirectTo: 'myRedirectUrl',
);
context.showSnackBar(
message: 'Please check your inbox for confirmation email.',
);
} on AuthException catch (error) {
...
} catch (error) {
...
}
return null;
}
As you can see, I pass additional data for username and language. How can I access this data in Supabase and save it into one of my tables?