ReactingMe
05/26/2023, 11:15 PMadmin@AFVFHGQBRQ6L7 AIKnowledgebase % npm install -S @supabase/supabase-js
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: class-variance-authority@0.4.0
npm ERR! Found: typescript@5.0.4
npm ERR! node_modules/typescript
npm ERR! typescript@"5.0" from the root project
npm ERR! peerOptional typescript@">=3.3.1" from eslint-config-next@13.2.4
npm ERR! node_modules/eslint-config-next
npm ERR! eslint-config-next@"13.2.4" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peerOptional typescript@">= 4.5.5 < 5" from class-variance-authority@0.4.0
npm ERR! node_modules/class-variance-authority
npm ERR! class-variance-authority@"^0.4.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: typescript@4.9.5
npm ERR! node_modules/typescript
npm ERR! peerOptional typescript@">= 4.5.5 < 5" from class-variance-authority@0.4.0
npm ERR! node_modules/class-variance-authority
npm ERR! class-variance-authority@"^0.4.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR!
Can you help resolve this? Thanks in advanceseeinplays
05/26/2023, 11:18 PMnobyf
05/26/2023, 11:49 PMkaswan24
05/27/2023, 7:19 AMskofff
05/27/2023, 8:19 AMWizzel
05/27/2023, 9:15 AMnot
filter.
This is what I currently have:
dart
return baseQuery
.select()
.not('my_column', 'cs', '{"value1", "value2"}')
.select();
but this returns rows where any of the following statements are true:
1. contains "value1" and not "value2"
2. contains "value2" and not "value1"
3. does not contain "value1" and not "value2"
How do I change the query so that I only get the 3. result?
Replacing the cs
operator with in
throws an error:
PostgrestException(message: "failed to parse filter (not.in.{"value1","value2"})" (line 1, column 5), code: PGRST100, details: unknown single value operator not, hint: null)
.Volxen
05/27/2023, 11:17 AMhttps://cdn.discordapp.com/attachments/1111976451638562857/1111976542969532416/image.png▾
brt
05/27/2023, 12:55 PMdart
await Supabase.initialize(
url: dotenv.get('SUPABASE_URL'),
anonKey: dotenv.get('SUPABASE_ANON_KEY', fallback: ''),
debug: false);
FirebaseMessaging messaging = FirebaseMessaging.instance;
NotificationSettings settings = await messaging.requestPermission(
alert: true,
announcement: false,
badge: true,
carPlay: false,
criticalAlert: false,
provisional: false,
sound: true,
);
...
final downloadedTraining = await Supabase.instance.client.storage
.from('general')
.getPublicUrl('trainings/2023-04-17.pdf');
...
final dt = await Supabase.instance.client.storage
.from('general')
.download('/trainings/2023-04-17.pdf');
...
And now I would like to mock the storage in order to always return an expected result when performing the e-2-e tests with patrol.
Is it possible mocking just what I need i.e. storage.from('...').download? How can I achieve it?
The two ways I've figured out are:
- create a mock client you can give it to supabase when initialize
is called (slow and complicated: you should check all the API calls and mock them)
- adopting Dependency Injection, creating an interface and implement it one with Supabase, and another one with a mock (mockito or so)
Supabase's IA talks about a supabase_flutter_test
library, but I think it's totally wrong 😅kameHame HA
05/27/2023, 1:10 PMYuu
05/27/2023, 1:52 PMts
const { data, error } = await supabase.storage.from('attachments').upload(`attachments/${uniqueString}`, file.bytes, {
contentType: file.type,
})
How I get the id of the storage object uploaded?darksim
05/27/2023, 2:32 PMdarksim
05/27/2023, 2:42 PMdmayo2
05/27/2023, 2:44 PMpostgres
but that doesn't work (the way I'm using it).
I'd also like a policy that will let my app select that table.
public.grammar_stats
This table get's updated when a user checks the grammar. With this new row inserted, the Trigger fires to update:
public.grammar_count
which has one row with two columns .id and .total
CREATE OR REPLACE FUNCTION update_grammar_count()
RETURNS TRIGGER AS $$
BEGIN
UPDATE grammar_count
SET total = total + NEW.char_count
WHERE id = 1;
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS grammar_count_insert_trigger ON grammar_stats;
CREATE TRIGGER grammar_count_insert_trigger
AFTER INSERT ON grammar_stats
FOR EACH ROW
EXECUTE FUNCTION update_grammar_count();
and this is not allowing an update when RLS is enabled:
-- Create a policy to allow system updates and inserts
CREATE POLICY allow_system_update_grammar_count ON grammar_count
FOR ALL
TO postgres
USING (true);
49Ryann
05/27/2023, 3:41 PMcreated_at: "2022-12-18T10:56:09+00:00"
Is there a way to auto format these through Supabase HTTP settings? or intercept them some how to make them into dates?
Currently I'm doing things like this to format nested strings into dates and it's becoming smelly! 💩
findAll$ = () => super.findAll$().pipe(
map(({data, ...others}) => ({
...others,
data: data && data.map(item => ({
...item,
last_message: {
body: item?.last_message?.body,
dateCreated: item?.last_message?.dateCreated ? new Date(item.last_message.dateCreated) : null
}
}))
})
)
)
Maybe even if this is something I can set in Postgres?Bibin
05/27/2023, 3:49 PMimport { createClient } from "@supabase/supabase-js";
const supabase = createClient(supabaseURL,supabaseKEY);
export default supabase;
where the parameters are my URL and KEY assigned to variables
I actually wanted a successful login implementation when I click the login button with the email and password it should verify it with the table in the database called User where I have attributes namely, a username and password. I dont' need a new user registeration or a signup , just a basic login function. And if the user entered credentials is equal to that of the ones in the User table then it should be redirected to another page (/homePage).
When I ran npm start in the terminal, site loads and in the login page when I click the login button ,it says "invalid credentials" which is written in the following logintrial.js although I provided the same username and password as of in the table. The file called logintrial will be put as an image next to this due to word limit
Please provide a good help. Looking forward for the fast reply.Following is each component code :
--------fetchUserCredentials.js-----------
import supabase from "../config/client";
const fetchUserCredentials = async () => {
const { data, error } = await supabase.from("User").select("*");
if (error) {
console.error("Error fetching user credentials:", error);
}
return data;
};
export default fetchUserCredentials;
https://cdn.discordapp.com/attachments/1112044804776394812/1112044805019684884/problem_Edited.jpg▾
https://cdn.discordapp.com/attachments/1112044804776394812/1112044805917249597/table.jpg▾
https://cdn.discordapp.com/attachments/1112044804776394812/1112044806475108392/Screenshot_20.png▾
laubonghaudoi
05/27/2023, 5:43 PM.is()
api like the JS library. How to you do that in Python?oracle
05/27/2023, 5:59 PMиuғe
05/27/2023, 6:34 PMhttps://cdn.discordapp.com/attachments/1112086537308479539/1112086537434312846/image.png▾
Aarush
05/27/2023, 7:30 PMsupabase.auth.signInWithOAuth
in SvelteKit with redirectTo set to an api route which does
ts
const code = url.searchParams.get("code");
if (code) {
await supabase.auth.exchangeCodeForSession(code);
}
with hCaptcha enabled in the auth settings, but I'm getting a AuthApiError: hCaptcha verification process failed
error whenever someone runs that particular api route (despite the signInWithOAuth method not having any captchaToken parameter in the options)formigueiro
05/28/2023, 1:15 AMwepsree
05/28/2023, 2:38 AMalana
05/28/2023, 3:30 AMhttps://cdn.discordapp.com/attachments/1112221280075264051/1112221280217866240/CleanShot202023-05-2720at2014.15.482x.jpg▾
ven
05/28/2023, 3:45 AMCREATE OR REPLACE FUNCTION set_claim() RETURNS TRIGGER AS $$
BEGIN
NEW.raw_app_meta_data = NEW.raw_app_meta_data || jsonb_build_object('role', 'USER');
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
any thoughts on the pros/cons of the new rewrite. seems to get the job done.alpi
05/28/2023, 3:52 AMash
05/28/2023, 11:42 AMStorageApiError: The resource was not found
.
const { data, error } = await supabase.storage
.from("user-files")
.createSignedUploadUrl(filename);
supabase
is an instance of the Supabase client initialized with the service role key as follows...
import { createClient } from '@supabase/supabase-js'
const supabase = createClient(supabase_url, service_role_key, {
auth: {
autoRefreshToken: false,
persistSession: false
}
})
Looking at the error logs for the Supabase Storage container running locally on Docker I see the following error...
DatabaseError: failed to retrieve bucket
at new DatabaseError (/app/dist/storage/errors.js:22:28)
at Database.<anonymous> (/app/dist/storage/database.js:105:35)
at step (/app/dist/storage/database.js:33:23)
at Object.next (/app/dist/storage/database.js:14:53)
at fulfilled (/app/dist/storage/database.js:5:58)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
status: 406,
postgresError: {
code: 'PGRST116',
details: 'Results contain 0 rows, application/vnd.pgrst.object+json requires 1 row',
hint: null,
message: 'JSON object requested, multiple (or no) rows returned'
},
metadata: { bucketId: 'upload' }
}
Weird because the list operation on the same bucket works fine, not sure why bucketId is "upload" in the metadata section above either.
Anybody have any ideas?salzar
05/28/2023, 12:07 PMonurhan1337
05/28/2023, 12:10 PMts
"use client";
import { createClientComponentClient } from "@supabase/auth-helpers-nextjs";
import { Session } from "@supabase/supabase-js";
import { useRouter } from "next/navigation";
async function AddCommment() {
const supabase = createClientComponentClient();
const router = useRouter();
async function signInWithGitHub() {
const { data, error } = await supabase.auth.signInWithOAuth({
provider: "github",
});
}
const handleSignOut = async () => {
await supabase.auth.signOut();
router.refresh();
};
return (
<div className="mt-10">
<button
onClick={() => {
signInWithGitHub();
}}
>
Sign In
</button>
{/* if user logged in */}
<button onClick={handleSignOut}>Sign Out</button>
</div>
);
}
export default AddCommment;
elhe26
05/28/2023, 12:48 PMぴんく
05/28/2023, 1:21 PMSELECT
(they do not need to login)
* users will never write to the database
* there is a GCP Cloud Function that performs a DELETE
and INSERT
to my table
Given this setup, should I use the service_role
API key for my Cloud Function? Or would it make more sense to setup a custom role?
If the latter is the case, I suppose I would have to setup a policy that checks for a predefined email
field, and also handle refreshing the JWTs every once in a while.
I didn't really see a section for service accounts in the docs, so I wanted to know how other people would handle this setup. Thanks in advance 🙏.Volxen
05/28/2023, 2:38 PM