ven
10/26/2022, 12:48 AMconst form = formidable({ multiples: true });
const client = await serverSupabaseClient(event);
const response = await new Promise((resolve, reject) => {
form.parse(event.req, (err, fields, files) => {
if (err) {
reject(err);
}
resolve({ fields, files });
});
});
const { fields, files } = response;
and then i rename my file removing any blank spaces const fileName = encodeURIComponent(
files.avatar.originalFilename.replace(/\s/g, '-')
);
and try to upload the file // upload the file to supabase storage
const { data, error } = await client.storage
.from('site')
.upload('public/' + Date.now() + '-' + fileName, files.avatar);
return data;
i get no error and there is no file in storage. any thoughts on what could be happening?Cory
10/26/2022, 1:29 AMferpintado
10/26/2022, 3:43 AMselect
off other variables like so:
.select(
`
${PROPS},
${DATABASE}!${FOREIGN_KEY.parent} (
${PROPS}
),
${vendorService.DATABASE}!${FOREIGN_KEY.vendor} (${vendorService.PROPS})
Now that I am trying to migrate to v2 typescript is throwing an error like the image.
Is there anything I can do to fix that?NanoBit
10/26/2022, 6:22 AMbensurf
10/26/2022, 8:01 AMrecipes
table:
id
title: text
author: text
method: text
Now I am unsure how I will store
- ingedrients (list of ingredients each with a quantity) e.g. "2 eggs", "30g sugar" ....
- tags (list of tags) e.g. "quick", "easy", "no-oven" ....
Any suggestions? I am brand new to sql type thingsGiuseppe
10/26/2022, 9:34 AMPatres
10/26/2022, 11:28 AMconst {error, data} = await supabase.from('google_reviews').update({ name: 'Nepal' }).select().eq('id', 1)
FunHellion
10/26/2022, 12:35 PMsql
(
(household_auth_for_heatpump(serial_number) AND has_permission(ARRAY['heatpumps.select.household'::text])) OR
(team_auth_for_heatpump(serial_number) AND has_permission(ARRAY['heaptumps.select.team'::text])) OR
(installer_company_auth_for_heatpump(serial_number) AND has_permission(ARRAY['heatpumps.select.company'::text]))
)
I was wondering if there is a way to get the operation from within the policy?
Kind Regards,
Bramtpz
10/26/2022, 12:41 PMblimey
10/26/2022, 1:06 PMINFO: Deploy to supabase/test-reports
ERROR: not found ACTIONS_DEPLOY_KEY, PERSONAL_TOKEN, or GITHUB_TOKEN
Not sure where to define any of those to make it succeed - I tried in github secrets but firstly it won't let me define GITHUB_ anything, and secondly PERSONAL_TOKEN didn't seem to work either...
It keeps trying every few hours to remind me - any hints?
e.g. https://github.com/rscorer/supabase/actions/runs/3306672164
Thanks!tpz
10/26/2022, 1:18 PMimport { createClient } from 'https://deno.land/x/supabase/mod.ts';
const supabase = createClient(
MY_SUPABASE_URL,
MY_SUPABASE_SERVICE_ROLE,
);
And when running ``supabase functions serve supaconnect --debug``
I got these:
Serving supabase/functions/supaconnect
2022/10/26 21:16:13 Sent Header: Host [docker]
2022/10/26 21:16:13 Sent Header: User-Agent [Go-http-client/1.1]
2022/10/26 21:16:13 Sent Header: Content-Length [736]
2022/10/26 21:16:13 Sent Header: Content-Type [application/json]
2022/10/26 21:16:13 Send Done
2022/10/26 21:16:13 Recv First Byte
Watcher Process started.
error: Uncaught TypeError: Cannot read properties of undefined (reading 'href')
if (!url) url = window.location.href
^
at getParameterByName (https://deno.land/x/gotrue@3.0.0/src/lib/helpers.ts:17:35)
at new GoTrueClient (https://deno.land/x/gotrue@3.0.0/src/GoTrueClient.ts:94:57)
at new SupabaseAuthClient (https://deno.land/x/supabase@1.3.1/src/lib/SupabaseAuthClient.ts:6:5)
at SupabaseClient._initSupabaseAuthClient (https://deno.land/x/supabase@1.3.1/src/SupabaseClient.ts:166:12)
at new SupabaseClient (https://deno.land/x/supabase@1.3.1/src/SupabaseClient.ts:69:22)
at createClient (https://deno.land/x/supabase@1.3.1/src/index.ts:11:10)
at file:///home/deno/functions/newhello/index.ts:4:18
This error shows only when calling ``createClient()``, please note that I provided supabase api url, both tried inside variable and string directly in parameters
Any help is greatly appreciated.
Thank youflapili (FR, bad EN)
10/26/2022, 1:43 PMbash
supabase db diff -f "add_functions" --debug > l
Error: Error starting shadow database: ERROR: syntax error at or near "COMMIT"
LINE 6: COMMIT;
any idea ?lewisd
10/26/2022, 2:19 PMconst { data, error } = await supabase
.from(LISTINGS_TABLE)
.select("*, comments:listingComments(count), likes:listingLikes(count)", { count: "estimated" })
I then have to access the amount of comments as listing?.comments[0]?.count
. Same thing with the likes: listing?.likes[0]?.count
I'd ideally like to just use listing?.likes?.count
or even better listing?.likes
kevmmm
10/26/2022, 2:42 PMdhruvraj
10/26/2022, 3:16 PMSarcodo
10/26/2022, 4:12 PMauth.uid() = user_id
but with a link to another table which contains the user_id columnRoygieBoosh
10/26/2022, 4:25 PMdrewbie
10/26/2022, 5:02 PMcreate trigger index_products_to_search
after insert on products
for each row execute procedure
public.send_to_webhook( 'http://172.17.0.1:54321/functions/v1/hello' );
Function
create extension http with schema extensions;
create or replace function send_to_webhook() returns trigger AS $trigger$
declare
rec RECORD;
payload TEXT;
column_name TEXT;
column_value TEXT;
payload_items JSONB;
begin
-- Set record row depending on operation
CASE TG_OP
WHEN 'INSERT', 'UPDATE' THEN
rec := new;
WHEN 'DELETE' THEN
rec := old;
ELSE
RAISE EXCEPTION 'Unknown TG_OP: "%". Should not occur!', TG_OP;
END CASE;
payload_items := coalesce(row_to_json(rec),'{}')::jsonb;
-- Build the payload
payload := json_build_object(
'timestamp',CURRENT_TIMESTAMP,
'operation',TG_OP,
'schema',TG_TABLE_SCHEMA,
'table',TG_TABLE_NAME,
'data',payload_items
);
-- Notify the webhook
perform extensions.http((
'POST',
TG_ARGV[0]::varchar,
ARRAY[http_header('Authorization','Bearer ANON_KEY')],
'application/json',
payload::varchar
)::http_request);
return rec;
end;
$trigger$ language plpgsql;
Edge Function
import { serve } from "https://deno.land/std@0.131.0/http/server.ts";
import { adminSupabaseClient } from "../_shared/supabase.ts";
serve(async (req) => {
try {
const payload = await req.json();
const { data } = payload;
const product = await adminSupabaseClient
.from("products")
.select("id")
.eq("id", data.id)
.single();
// data.id is the ID of the return rec from the function, but trying to select it returns no results.
if (!product.data) {
throw new Error(`No Product Found for ${data.id}`); // This error throws and it has the id from data
}
return new Response(JSON.stringify(data), { headers: { "Content-Type": "application/json" } });
} catch (e) {
throw new Error(e);
}
});
And then in the above url it's an edge function that tries to select that product but no product is returned. The function has access to the record as its provided in the send_to_webhook function, but retrieving a record by that id returns no results.killjoy
10/26/2022, 5:11 PM> supabase@1.11.2 preinstall /Users/.../node_modules/supabase
> node scripts/preinstall.js
internal/process/esm_loader.js:74
internalBinding('errors').triggerUncaughtException(
After looking into it deeper it seems like the preinstall script attempts to download the binary from https://github.com/supabase/cli/releases/download/v0.0.0-automated/supabase_0.0.0-automated_darwin_amd64.tar.gz
A path which indeed does not exist. Why is it trying to download from v0.0.0-automated instead of the actual desired release (1.11.2)?Vik
10/26/2022, 6:01 PMexport const handleUpdateUsername = async (id: string, username: string) => {
const { data, error } = await supabase
.from('profiles')
.update({ username: username })
.match({ id: id })
.single();
if (error) {
console.log('error', error);
return error;
} else {
console.log('data', data);
return data;
}
};
LawJolla (Dennis Walsh)
10/26/2022, 6:24 PMjbergius
10/26/2022, 6:34 PMfadethegap
10/26/2022, 6:42 PMsilentworks
10/26/2022, 8:26 PMOliver W
10/26/2022, 8:43 PMprividers={["google"]}
gets a warning message in the console:
Warning: Received false
for a non-boolean attribute loading
.
If you want to write it to the DOM, pass a string instead: loading="false" or loading={value.toString()}.ZetiMente
10/26/2022, 8:44 PMimages:profile_id=eq.${profileId}
)
.on('INSERT', (payload) => {
outputPictureURL = payload['new']['image'];
});
clearTimeout(timeoutId);
})
.subscribe();`
However, this new code now fails at filtering:
`supabaseSubscription = supabase
.channel(public:images:profile_id=eq.${profileId}
)
.on(
'postgres_changes',
{ event: 'INSERT', schema: 'public', table: 'images' },
(payload) => {
console.log('payload is: ', payload);
outputPictureURL = payload['new']['image'];
});
clearTimeout(timeoutId);
}
)
.subscribe();`
Could someone please tell me the correct syntax now to do this?paxmx
10/26/2022, 9:34 PMselect
ST_X(location) AS x1,
ST_Y(location) as y1,
location as loc
from properties
where id = 1;
However result shows:
Failed to run sql query: function st_x(geography) does not exist
I have tripled check that postgis extension is enabled, what else is a must for this query to work? Or maybe I have an error in my query? Regards.Profilüfter
10/26/2022, 10:46 PMsupabase db remote set "..."
to save the connection string of my docker-deployed database and then supabase db push
to execute all migrations on the database.
This all happened inside a docker container with the only purpose to run migrations.
However the commands have changed (to be expected in such a huge version jump) but I cannot find a possibility to set a local database as the target for db push
... I looked at the source code of the CLI and it seems the only way to set the database is with supabase link
but that only works with supabase-hosted projects. Is this now vendor lock-in, work in progress or am I missing something?lonelil
10/27/2022, 4:35 AM