kevlust
05/05/2023, 3:48 PMven
05/05/2023, 4:39 PMasync function getOne() {
const { data, error } = await supabaseClient.functions.invoke("contact", {
method: "GET",
body: JSON.stringify({ id: "23" }),
});
console.log(data, error);
}
and get an error. how to send the request method? tia ❤️Whoman
05/05/2023, 6:28 PMSig
05/05/2023, 6:43 PMavatar_url
to 'avatar.svg' which is hosted in my avatars bucket. I can manually add the value to a row, but when a new user is created it always defaults to null
in stead.
I have attached a screenshot of the column settings, any suggestions are highly appreciated.
https://cdn.discordapp.com/attachments/1104116223647686817/1104116560446107718/CleanShot_2023-05-05_at_20.44.39.png▾
alpha_
05/05/2023, 7:02 PMfull_name
in profiles table and just implemented the same using user management starter.
Everything was pretty good so far but, now when I look at the profiles table, it looks like when someone signs up, a profile is being created (as per the SQL query and trigger from user management starter) even without their email being verified. I probed google a bit, but couldn't find a clear solution on how to create a user profile only when the user email is being verified?Revaycolizer
05/05/2023, 7:09 PMconst User =async()=>{
const {data:{user}} = await supabase.auth.getUser()
if(user){
const { data:files } = await supabase
.from('category')
.select().eq('user',user.id)
console.log(files)
if(files){
console.log(files)
const posts = []
for (const file of files) {
const { data:post } = await supabase.storage.from('files').createSignedUrl(file.vname, 3600000, {
transform: {
width: 200,
height: 200,},
})
if(post){
posts.push(post)
// const diwn = await supabase.from('category').select().eq('vname',file.name)
setDownload(posts)
// setDfiles(diwn)
}
}
}
BrendanH117
05/05/2023, 7:32 PMsupabase init --debug
returns Error: Project already initialized. Remove supabase\config.toml to reinitialize.
. I'm running this in a project directory where only .vscode
exists, no other files or folders. I can't find any other config.toml files on my PC. Any help or pointers is appreciated.leleco
05/05/2023, 7:49 PMlet client = SupabaseClient(supabaseURL: URL(string: "myurl")!, supabaseKey: "my-api-key")
func getAllLeagues() {
let query = client.database.from("Leagues").select(columns: "id").single();
Task {
do {
let response: [League] = try await query.execute().value
print(response)
} catch {
print(error)
}
}
}
timm
05/05/2023, 8:08 PMsupabase.auth.admin.createUser
)
* I generate a JWT using those details.
* I can pass the JWT token to client via an API, and inject it into `createClient`'s global.headers
, which works (for a while)
* supabase-auth-token
cookie does not get set.
* Stops working once JWT expires.
My hope was to somehow "programmatically" sign-in as a user, and let Supabase Auth handle everything. Is this possible, using JWT or another approach?Revaycolizer
05/05/2023, 8:12 PMconst User =async()=>{
const {data:{user}} = await supabase.auth.getUser()
if(user){
const { data:files } = await supabase
.from('category')
.select().eq('user',user.id)
if(files){
const posts = []
for (const file of files) {
const { data:post } = await supabase.storage.from('files').createSignedUrl(file.vname, 3600000, {
transform: {
width: 200,
height: 200,},
})
if(post){
posts.push(post)
setDownload(posts)
}
}
}
}
}
garyaustin
05/05/2023, 9:17 PMUPDATE weather SET temp_lo = temp_lo+1, temp_hi = temp_lo+15, prcp = DEFAULT
Is the normal format for multiple columns.
If multiple sets work, you at least need a comma.SaltySesame
05/05/2023, 9:36 PMjs
import {ref} from 'vue'
const supabase = useSupabaseClient()
const firstName = ref('')
const lastName = ref('')
const email = ref('')
const password = ref('')
async function register() {
const {data, error} = supabase.auth.signUp({
email: email.value,
password: password.value,
//additional user data
options: {
data: {
first_name: firstName,
last_name: lastName
}
}
})
}
const user = useSupabaseUser()
onMounted(()=>{
watchEffect(()=>{
if(user.value){
navigateTo('/profile')
}
})
})
Below is the problematic code.
Retrieval JS in profile page (Full code):
js
//unimportant (auth middleware)
definePageMeta({
middleware: [
'auth'
]
})
//THE PROBLEM
const user = useSupabaseUser() //user object (It's OK)
const name = user.value.user_metadata.first_name //undefined
//user_metadata alone works too
(I'm pretty new to both. It's my first time using Supabase. Sorry if the question is bad or that's the wrong place to ask)joshu.a
05/05/2023, 10:26 PMhttps://cdn.discordapp.com/attachments/1104172395713019996/1104172396400873513/Screen_Shot_2023-05-05_at_6.25.13_PM.png▾
dave
05/05/2023, 10:41 PMSig
05/05/2023, 11:50 PMcreate table images (
id integer not null generated by default as identity primary key,
owner_id references auth.users on delete cascade not null,
updated_at timestamp with time zone,
image_url text not null,
location text,
camera text,
aperture text,
shutter text,
iso text,
);
alter table images
enable row level security;
-- Create a policy to allow anyone to insert into the images table
create policy "images are viewable by everyone." on images
for select using (true);
-- Create policy for anyone to inert images
create policy "Anyone can insert new images." on images
for insert using (true);
-- Create a policy to allow only owners to update their own images
create policy "Owner can update their own images." on images
for update using (auth.uid() = owner_id);
-- Set up Storage!
insert into storage.buckets (id, name)
values ('image_bucket', 'image_bucket');
-- Set up access controls for storage.
-- See https://supabase.com/docs/guides/storage#policy-examples for more details.
create policy "Images are publicly accessible." on storage.objects
for select using (bucket_id = 'image_bucket');
create policy "Anyone can upload an image." on storage.objects
for insert with check (bucket_id = 'image_bucket');
Jolly Joy
05/06/2023, 1:50 AMrafael
05/06/2023, 2:13 AMsupabase db remote commit
and a migration file will be created inside the supabase/migrations folder. But I'm not sure what is the proper way to create a new one and deploy it to production.
Actually, would be really nice to be able to create those DB functions like Edge functions, and functions located in the functions folder etc (just to keep it organized) instead of in the same migration file.
There is any good way to keep all organized?dave
05/06/2023, 5:02 AMAkashSh
05/06/2023, 5:50 AMKai___
05/06/2023, 5:57 AMFluck
05/06/2023, 5:59 AMconst dataUrls = formData.getAll('files')
const imageUuidList = [];
const promises = [];
for (const file of dataUrls) {
const imageId = uuid();
imageUuidList.push(imageId);
// Upload the File object to Supabase Storage
promises.push(supabase.storage.from("listing_images").upload(imageId, decode(file), {
contentType: 'image/*'
})
);
}
And here is the code for the form:
let selectedImages: string[] = [];
let selectedBlobs: string[] = [];
let files: FileList;
async function onChangeHandler(e: Event) {
if (selectedImages.length + files.length > 6) {
alert('You can only upload a maximum of 6 images.');
return;
}
const file = files.item(0);
if (file != null) {
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = (event) => {
if(!event.target) return;
const image = event.target.result as string;
selectedImages.push(image);
const data = image.split(',');
selectedBlobs.push(data[1]);
selectedBlobs = selectedBlobs.slice();
selectedImages = selectedImages.slice();
};
}
}
RyanLuttrell
05/06/2023, 6:08 AMrico.wtf
05/06/2023, 6:23 AMfull_name
that merges first_name
and last_name
chit
05/06/2023, 11:25 AMexport const supabase = createClient<Database>(supabaseUrl, supabaseAnonKey);
supabase is created using this key, I also have the correct schema.ts
export interface Database {
public: {
Tables: {
...
but then when I try to insert stuff, it says my types are wrong, when that is the exact type definition in the schema.ts file
https://cdn.discordapp.com/attachments/1104368222721032192/1104368223052365865/image.png▾
Mashwishi
05/06/2023, 11:44 AMtsx
const supabaseAccessToken = await session.getToken({
template: 'Supabase'
});
const supabase = await supabaseClient(supabaseAccessToken);
const { data } = await supabase
.from('purchase')
.eq('id', referenceNumber)
.select()
Hugos
05/06/2023, 11:49 AMsql
create table
public.orders (
id uuid not null,
status public.order_status not null,
city text not null,
postal_code text not null,
address text not null,
customer_email text not null,
created_at timestamp with time zone null default now(),
constraint orders_2_pkey primary key (id)
) tablespace pg_default;
And my order_products table:
sql
create table
public.order_products (
order_id uuid not null,
product_id uuid not null,
quantity integer not null,
price double precision not null,
constraint order_products_pkey primary key (order_id, product_id),
constraint order_products_order_id_fkey foreign key (order_id) references orders (id),
constraint order_products_product_id_fkey foreign key (product_id) references products (id)
) tablespace pg_default;
I want to query an order along with the products from that order with the Javascript client, is this possible, if so, how? If not, what would be a work around.
https://cdn.discordapp.com/attachments/1104374274766155796/1104374274921332848/image.png▾
bingbong
05/06/2023, 12:28 PMMasini
05/06/2023, 1:14 PMAgon
05/06/2023, 1:31 PMSearched for a foreign key relationship between 'profiles' and 'users' in the schema 'public', but no matches were found.
this happens when calling
dart
await Supabase.instance.client.rest
.from('profiles')
.select<PostgrestList>('*, users(*)')
table profiles
has a column user_id
which is a foreign key pointing to table users
rls is turned off