All Questions
Tagged with supabase supabase-database
376
questions
27
votes
1
answer
44k
views
How to query using join in Supabase?
In Supabase documentation, it explains this as how you would "join" tables to get data
const { data, error } = await Supabase
.from('countries')
.select(`
name,
cities (
...
22
votes
1
answer
16k
views
Module not found: Can't resolve 'encoding' in '/vercel/path0/node_modules/cross-fetch/node_modules/node-fetch/lib'
Has anyone come across this non-breaking warning issue that you get with the npm package: @supabase/supabase-js
The warning message:
warn - ./node_modules/cross-fetch/node_modules/node-fetch/lib/...
21
votes
4
answers
27k
views
How to get "COUNT(*)" in Supabase
I want to retrieve row count in Supabase.
I am guessing it would be something like this:
const { data, error } = await supabase
.from('cities')
.select('name', 'COUNT(*)')
Is this possible with ...
19
votes
2
answers
9k
views
How can I create an enum column in Supabase?
I want to create an enum column in a Supabase table. Supabase uses Postgres under the hood, so I understand that technically it is possible if I do it manually using SQL. But is there any way I can do ...
18
votes
1
answer
8k
views
How to insert in multiple tables with a single API call in Supabase
This is the simplified structure of my tables - 2 main tables, one relation table.
What's the best way to handle an insert API for this?
If I just have a Client and Supabase:
- First API call to ...
16
votes
2
answers
12k
views
INSERT into the table and return id of the record Supabase JS
Based on the docs, inserting a new record
const { error } = await supabase
.from('countries')
.insert({ name: 'Denmark' })
returns
{
"status": 201,
"statusText": "...
9
votes
3
answers
8k
views
Supabase, filter by column value of foreign key row
I am trying to figure out how to implement a query in supabase:
Schema
CREATE TABLE cars
(
id SERIAL PRIMARY KEY,
brand TEXT
);
CREATE TABLE stores
(
id SERIAL PRIMARY KEY,
car INT ...
8
votes
3
answers
9k
views
delete associated records in Supabase
When using Supabase, is there a clean / simple way in which I can delete all associated records together with an item? Say I have Posts and a Post can have many Comments. When I delete the Post I want ...
7
votes
1
answer
3k
views
Can't migrate schema using Prisma with Supabase
When I use the Postgres database on Supabase I run the following command, npx prisma migrate dev --name init, but I get the following error (first command in screenshot):
Error: db error: FATAL: ...
7
votes
2
answers
2k
views
PostgREST - Add authenticated user id on insert
I need to automatically add an author of an inserted row in one of its columns. I am using postgREST (using Supabase cloud service) and I don't want users to add whoever they want as the author. Is ...
6
votes
2
answers
5k
views
How to download table created in supabase
I've created a table in supabase and filled it up with some data, Is there any way to download this table without interacting with supabase client?
I want to save this as CSV file for future use but ...
6
votes
2
answers
7k
views
Error: Get config: Unable to establish a connection to query-engine-node-api library in Prisma and nextjs
I use nextjs fresh project with Prisma and supabase database. I'm using ubuntu.
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04 LTS
Release: 22.04
Codename: ...
6
votes
1
answer
3k
views
supabase query for one-to-one foreign key, return single value (not array)
How can I query a one-to-one relationship with foreign key in supabase?
My tables:
games (id, created_at, played_at)
results (game_id, key)
Data: games
("id": 1, "created_at": &...
5
votes
1
answer
4k
views
Is there a way to perform full text search on multiple columns on Supabase with Javascript?
I've tried using many symbols to separate columns; ||, |, &&, & with and without spaces.
For instance
.textSearch("username, title, description", "...");
.textSearch(&...
5
votes
1
answer
4k
views
How To Update Entire Row In Supabase Table? (Getting 400 Error)
I am trying to make an input form where the user can change several values in one row simultaneously which get submitted to the database using the update() method. The values are being read from the ...
5
votes
2
answers
891
views
Only allow read if user has exact document id postgresql row level security/supabase
Is there a way for a user to only be able to read a document only if they have the exact document ID?
I want to avoid creating users, so the only security is a random guid saved in browser memory - ...
5
votes
1
answer
3k
views
`supabase start` on Windows failing
I am running Windows 11 and have installed the supabase cli via Scoop per the documentation. I am adding it to an existing repository so I have already ran the below commands with no issue:
supabase ...
5
votes
1
answer
2k
views
Failed to create and edit tables in Supabase, "Failed to create pg.columns:..."
I have failed to create or edit tables in Supabase. It is showing an error message "Failed to create pg.columns: must be the owner of event trigger pgsodium_trg_mask_update". I think it has ...
5
votes
1
answer
2k
views
Access supabase database from edge function as admin
I'm coming from Firebase Function... Where I can use the Admin Library to access database from the Function bypassing all security rules? On supabase I didn't yet find a way to do that, the ...
5
votes
2
answers
3k
views
How to pull data from my production supabase database into my local supabase database
I have been trying to fix this problem, I could not search any documentation for this specific problem. I have everyhing setup, the project is linked, the docker is running, I just can not figure out ...
5
votes
1
answer
1k
views
How to upload file from python Flask web app to Supabase Storage
I want to be able to upload a file from Flask to Supabase Storage, but it only has documentation for the javascript api link to docs.
Also, I can't find any examples or any open source project that ...
4
votes
1
answer
6k
views
Supabase: How to automatically update a timestamp field after updating a row?
What DB I am using?
Supabase hosted version
What do I need?
After I update a row with .update({ name: 'Middle Earth' }) method I need to
automatically update also a timestamp in my table.
How can ...
4
votes
1
answer
6k
views
supabase.auth.getUser() returns error on vue-router route guard
I am attempting to build a Vue application that uses Supabase authentication. Inside one of the route guards in the router file, I implemented supabase.auth.getUser() in order to retrieve the user ...
4
votes
1
answer
5k
views
Update multiple rows in a single query in a Supabase Database (postgres)
I looking to update multiple rows via a single query in Supabase. I'm struggling to find an example of how to do it online.
For this example here is how the data exists the database's 'food' table:
...
4
votes
1
answer
2k
views
"Uncaught Error: More than one relationship was found" with Supabase client query
I'm building a multitenant app and running into an error after adding multiple relations that point to the same table:
Uncaught Error: More than one relationship was found for teams and users
When ...
4
votes
2
answers
897
views
Supabase realtime connection failing when custom JWT is used
I'm using supabase self-hosted and auth0 for my authentication instead of the default authentication provided by supabase. So I'm signing my auth0's payload with supabase secret and sending it in ...
4
votes
1
answer
2k
views
Supabase dynamic RPC function
I am looking to create an RPC for grabbing distinct values of a column but I am going to be doing this across multiple tables and I don't want to have to write this function over and over for each ...
4
votes
1
answer
1k
views
Supabase database size issue [closed]
I am quite new to Supabase.
Please clarify this:
I have a table in the database and its only 32KB in size.(2 columns and 2 rows of data only)
So why it is showing a Database Space Usage (under ...
4
votes
2
answers
8k
views
new row violates row-level security policy for table "tasks"
I am new to supabase and am trying to integrate my Todo App made with BlueBase, a Framework based on react and react native. And, I am facing such a problem.
CreateTaskScreen.tsx
import React from '...
4
votes
1
answer
716
views
Supabase triggers : ERROR: function charindex(unknown, text) does not exist (SQLSTATE 42883) (SQL)
I have two tables auth (this is the default one given by supabase) and profiles
when a new row is added in auth table I want a new row with the data added in auth table to be added in profiles tables ...
4
votes
1
answer
3k
views
Unable to push local migrations to Supabase through CLI
I tried to push the local migrations to the supabase database through its cli with the command supabase db push. The error it is showing me is:
Error: ERROR: must be owner of table users (SQLSTATE ...
4
votes
2
answers
4k
views
Supabase not allowing upload of files into storage bucket
I have a simple script for uploading a .txt file into a Supabase bucket named 'training-data'. The bucket was made public, and I made sure to include the necessary storage/object policies in order to ...
4
votes
2
answers
3k
views
Supabase "TypeError: fetch failed"
I am making a to-do list application with Supabase and NextJS-13 and while fetching the lists from Supabase, the server gave me this error
Error Image
My List table on Supabase has three columns:
id
...
3
votes
2
answers
4k
views
Cannot access env variables next.js [duplicate]
I'm creating an app with Next.js and Supabase. When I create the client in /utils/supabase-client.js, it throws the error that Error: supabaseUrl is required..
Here is my file:
import { createClient } ...
3
votes
1
answer
9k
views
Role based authentication in Supabase
I am trying to make policy in supabase where a user with admin role can only get list of employees whose role are "agent"
There is a "users" table and I am trying to add following ...
3
votes
1
answer
449
views
Using supabase.auth.getSession() is potentially insecure
I am using Supabase in my Next.js application.
I have initialised Supabase as shown below. This process is even mentioned in their official documentation.
utils/supabase/server.js
'use server'
import ...
3
votes
1
answer
2k
views
How to add Supabase Order by in get request using Postman
I need to add order in supabase result while calling the supabase bash in postman.
I am doing same in flutter like below
Future getPropertiesFromBirmingham() async {
var response = await client
...
3
votes
1
answer
876
views
Supabase and Google Apps Script
Is it possible to use Supabase with Google Apps Script (GAS)?
I'm new to Supabase and I've never tried to import external library to GAS before. I'm planning to use Supabase as a database for my ...
3
votes
1
answer
682
views
Query a timestamp range in supabase
I have a table in my supabase database with two columns start end end. Both are of type timestampz. Now I want to query all entries where the current timestamp (Date.now()) is inbetween start and end.
...
3
votes
2
answers
2k
views
How to reset the auto incremented id column to 1 whenever I seed the database in postgreSQL?
I am using Supabase as a backend which provides postgres as its database and prisma for my next-js app. I wanted to seed some dummy data into the database. The first time I run the seed script, ...
3
votes
1
answer
733
views
How to make a boolean form input in supabase using nextjs server actions?
I am trying to make a form to submit data to supabase (with nextjs 13).
I can submit a string input. I am trying to add a boolean field.
I have commented out the 'published' fields in this form. If I ...
3
votes
2
answers
1k
views
How to modify a Supabase table from the dashboard UI or the Supabase SQL editor?
Whenever I try to modify an existing table in the Supabase dashboard, I get this error "Failed to pg.columns: must be owner of table <table_name>". This seems to be like a permission ...
3
votes
1
answer
939
views
Can't update an image from the bucket
I've been trying to update a single file within a folder in the bucket that i created but when i go to update with a new image from the front does not update the image and gives the following error.
...
3
votes
1
answer
1k
views
How to link a storage bucket file into an item in a table
How can I link a file in my storage bucket into a table?
Let's say I have an item like this
Name: user, CreatedAt: date, pfp: storageFile
I want the file to be linked to the pfp field.
3
votes
1
answer
2k
views
supabase: how to reference files within tables
I want my users to be able to upload reports (PDFs). For this purpose, I have created a table of "reports" and thought that I can reference the object stored there. Therefore I created a ...
3
votes
1
answer
1k
views
Supabase Self hosting issue
I am trying to host Supabase with a separate PostgreSQL DB. According to their docs, they say that Supabase uses pgjwt for auth. However, AWS RDS or Azure PosrgreSQL doesnt not support pgjwt.
Is ...
3
votes
0
answers
390
views
Supabase SELECT with function call
From Javascript, I want to call a function in my supabase select statement (funcition name is id_encode in this example):
const { data, error } = await supabase
.from('table')
.select(&...
3
votes
0
answers
208
views
Supabase check whether a user is currently in/listening to a realtime channel from postgres function
How can one, from a postgres function, check whether a user is currently in/listening to a realtime channel?
I want to create notification entries in the database only if the user is not currently ...
2
votes
3
answers
4k
views
I can’t get Supabase real-time listen to Postgres changes to work
Inspired by the Supabase docs, I have this code in a React Native app:
useEffect(() => {
if (session?.user?.id === null) return
const channel = supabase
.channel('value-db-changes', { ...
2
votes
2
answers
2k
views
Uploading Base64 images to supabase
My website wants to reduce the amount of things users can do with the images...so for added security, we want to keep the image sources as a base64 strings instead of a supabase storage URL. Is this ...