KrishenK 君主
02/02/2023, 2:39 PMjs
this.channel.on('postgres_changes', { event: '*', schema: '*' }, data => console.log('RECV', data));
After I subscribe to a channel. Because it works well when I listen to a presence
and a broadcast
but not postgres_changes
.
Is it normal? Or there is something wrong with my code?Kjell
02/02/2023, 3:21 PMpermission denied for schema realtime
I already added an endpoint for the realtime schema through the interface. I did not find any option to give access to the schema through queries.
I also tried to give access rights through postgresql commands GRANT USAGE ON SCHEMA realtime TO postgres, anon, authenticated, service_role, dashboard_user, authenticator, supabase_auth_admin, supabase_admin,
This did not seem to help.
How to continue?Trevvy
02/02/2023, 3:36 PMzeedee
02/02/2023, 6:11 PMpers0n
02/02/2023, 6:58 PMjs
import { createClient } from '@supabase/supabase-js';
export const supabase = createClient(
process.env.NEXT_PUBLIC_SUPABASE_URL,
process.env.NEXT_PUBLIC_SUPABASE_KEY
)
And then I try to display the data on the page in my index.js file:
js
import { supabase } from '../utils/supabase'
export default function Home({ lessons }) {
console.log({lessons})
return (
<div className="flex flex-col items-center justify-center min-h-screen py-2">
{lessons.map(lesson => (
<p key={lesson.id}>{lesson.title}</p>
))}
</div>
);
}
export const getStaticProps = async () => {
const {data: lessons} = await supabase.from('lesson').select('*');
return {
props: {
lessons,
},
};
};
I attached an image of the empty array I get logged.
In my database I have a "lesson" table with two rows.
Are there some permissions you need to turn on in the settings? I am just trying to display the two rows in my database. Any advice helps. Thanks.nickbrinser
02/02/2023, 7:03 PMgetServerSideProps
when using createServerSupabaseClient()
. I was under the impression that the server client used the service role key and would bypass RLS. Has this changed?christer
02/02/2023, 7:59 PM{
"url": "/api/",
"statusCode": 500,
"statusMessage": "",
"message": "main.createClient is not a function",
"stack": ""
}
From this code:
import { createClient } from '@supabase/supabase-js'
export default defineEventHandler( async (event) => {
const runtimeConfig = useRuntimeConfig()
const supabase = createClient(runtimeConfig.supabase_url, runtimeConfig.supabase_service_role)
PS The code lives in the /server/api folderluke90275
02/02/2023, 8:18 PMyayza_
02/02/2023, 8:20 PMsql
create or replace function delete_product (product_id integer, image_path text)
returns boolean
language plpgsql
as
$$
begin
delete from public.products where id = product_id
delete from storage.public where image_path = image_path
return true
end;
$$
and then in js eg.
js
const product = { id: 2, image_path: 'product_images/a7pk014t92u09pa681c93w4y'}
const { data, error } = await supabase.rpc('delete_product', { product_id: product.id, image_path: product.image_path })
does that mean all three statements will either success or fail like that?El Inge
02/02/2023, 8:26 PMawait supabase
.from('BotRex_Database_Client_Info')
.select('language')
.where({ phone_number: number })
.eq(languages);
Import supabase in my config file:
const { createClient } = require("@supabase/supabase-js");
const SUPABASEURL = process.env.SUPABASE_URL;
const SUPABASE_KEY = process.env.SUPABASE_ANON_KEY`;
const supabaseClient = createClient(SUPABASEURL,SUPABASE_KEY);
module.exports = {
supabaseClient
};
And call it in my file as follows:
const supabase = require("../config");
I don't know if I'm importing something wrong, but the connection works but the code stops at supabase.from('BotRex_Database_Client_Info')
which maybe is an error on my part.ymahmo
02/02/2023, 9:29 PMDidier Catz
02/02/2023, 9:52 PMjinsley8
02/02/2023, 10:04 PMfts
column and index like this:
sql
ALTER TABLE public.profiles ADD COLUMN fts tsvector GENERATED ALWAYS AS (to_tsvector('english', coalesce(name,'') || ' ' || description)) stored;
CREATE INDEX IF NOT EXISTS profile_fts ON public.profiles USING GIN (fts);
https://supabase.com/docs/guides/database/full-text-search#match-any-search-wordsSquadz
02/02/2023, 10:05 PMFluffySmiles
02/02/2023, 10:06 PMpickwickian
02/02/2023, 10:26 PMusers
table directly.
For resetting password, there's two columns. recovery_token
and recovery_sent_at
- I am generating the values for both of those in my code and sending the email with a link to my own web app. Then with the token they can set a new password, which is stored in the encrypted_password
column.
The problem I am having, is the GoTrue library has a method called`hashPassword`( https://github.com/supabase/gotrue/blob/d536ed5ae341e818d8e1d83e83d237ad3c556e4a/models/user.go#L189) that calls a bcrypt implementation written in Go: https://pkg.go.dev/golang.org/x/crypto/bcrypt#GenerateFromPassword that uses a "Cost" of 10.
They don't expose a method for this in their JS library. The Node implementations of bcrypt don't use cost, they let you specify a number of salt rounds to use.
So even though I am hashing the new password with bcrypt, it's incompatible with their login system. I really hope there's a way around this, because it's the only thing stopping me from integrating the full flow into my own application code.logemann
02/02/2023, 10:27 PMInASunshineState
02/02/2023, 10:56 PM{
"code": "22P02",
"details": "Array value must start with \"{\" or dimension information.",
"hint": null,
"message": "malformed array literal: \"\""
}
The function knows where it couldn't proceed but if it says "Oh well the issue is where the right parenthese is" in a function with twenty lines of right parentheses, I am not sure how to address that.
I am calling an RPC using the JS client and I am supplying params the same way as I always do with every other RPC (which work just fine) and there actually aren't any errors when doing the "create or replace" so I am not sure what's going on.cncpowerhour
02/02/2023, 11:22 PMb12d5cab-8d8b-43d6-b658-10812de0adbe
)
.on('UPDATE', (data) => {
console.log(data)
})
.subscribe()
This is slightly modified code from these two videos showing realtime subscriptions:
(the table id is correct and that exact .eq works elsewhere in my code, and if I remove it and just subscribe to the whole table, that's when I get the "from(...).on" variation of the error message)
Is there a different way I should be doing this?Ethanxyz
02/03/2023, 12:19 AM"message": "An invalid response was received from the upstream server"
.
Postgres Logs read :`cannot drop constraint users_email_key on table users because other objects depend on it`
I had never come across this issue using authentication before - So I suspect it is due to the database restore.
Any ideas ?nateland
02/03/2023, 1:30 AMpublic.clients
points to auth.users
in constraint clients_id_fkey
. Please add auth
to your schemas
property and run this command again.Trevvy
02/03/2023, 1:31 AMCool Bean
02/03/2023, 2:17 AMalana
02/03/2023, 3:13 AMupdate rsvps set status = 'not attending' where id='b57b4ac0-de3a-4bb7-8511-ecb4c30d2d25'
and this is what i have in javascript:
console.log(rsvp);
console.log(rsvpStatus);
let { data, error, status } = await supabase
.from("rsvps")
.update({ status: "not attending" })
.eq("id", rsvp);
the console.logs before show that rsvp = b57b4ac0-de3a-4bb7-8511-ecb4c30d2d25 and i've tried replacing rsvp with that string and it still doesn't work. the query is returning a 204 status as expected. any ideas what's wrong or how to go about debugging this???jh
02/03/2023, 4:57 AMsql
create schema private;
create table salaries (
id bigint generated by default as identity primary key,
salary bigint not null,
actor_id bigint not null references public.actors
);
create table private.salaries (
id bigint generated by default as identity primary key,
salary bigint not null
);
I attempt to run supabase db dump --debug
but get the following error:
2023/02/02 20:50:56 Recv First Byte
pg_dump: error: query failed: ERROR: permission denied for schema private
pg_dump: detail: Query was: LOCK TABLE "private"."salaries" IN ACCESS SHARE MODE
2023/02/02 20:50:58 Sent Header: Host [docker]
2023/02/02 20:50:58 Sent Header: User-Agent [Go-http-client/1.1]
2023/02/02 20:50:58 Send Done
2023/02/02 20:50:58 Recv First Byte
Error: Error running pg_dump on remote database: error running container: exit 1
I then attempted to do the same using pg_dump, but I also get this same error.
Any suggestions on what I may be doing wrong?jh
02/03/2023, 5:20 AMjinsley8
02/03/2023, 7:35 AMjs
import type { NextApiRequest, NextApiResponse } from 'next';
import { getSupabaseServicePublic } from '@/utils/initSupabaseService';
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
const { user_id } = req.query as { user_id: string };
const supabaseService = getSupabaseServicePublic();
switch (req.method) {
case 'GET':
try {
// Check is user exists in Supabase
const { data, error } = await supabaseService
.from('users')
.select('id, email_address, email_verified')
.eq('id', user_id)
.single();
if (error) {
throw new Error('User does not exist!');
}
return res.status(200).json({ user: data });
} catch (error) {
return res.status(400).json(null);
}
default:
res.status(405).send({ message: 'Method not allowed' });
break;
}
}
Skills
02/03/2023, 8:38 AMlake_mattiato
02/03/2023, 9:00 AMjoni.giuro
02/03/2023, 9:26 AMjs
onMount(async () => {
const { data, error } = await supabase.auth.getSession()
invalidateAll();
user.set(data.session?.user);
loading = false
if (data.session?.user == undefined) {
goto('/')
}
});
User page:
js
onMount(() => {
supabase.auth.onAuthStateChange(( _, session) => {
user.set(session?.user);
loading = false
if(session?.user){
loadAnomalies();
}
});
})
Note that if I tab out of the page and back in, it suddenly works, the loader disappears and I see the user content