Questions tagged [supabase-database]

Supabase is a database solution powered by PostgreSQL. Under the hood, Supabase uses PostgREST, an open source tool to make automatically create REST API for PostgreSQL databases. Supabase utilizes row level security feature on top of PostgREST to provide authorization. Use this tag when you are having problems, and not to ask for new features.

Supabase Database is a component of Supabase that automatically creates RESTful APIs for your Supabase database backed by PostgreSQL. Under the hood, Supabase uses PostgREST, an open source tool to create REST APIs for your PostgreSQL database. Supabase utilizes row level security feature on top of PostgREST to provide authorization. Use this tag when you are having problems, and not to ask for new features.

Supabase Database comes with:

  • intuitive table editor
  • clients in various languages to communicate with the database
  • SQL editor to easily run SQL on your database
330 questions
23
votes
1 answer

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 ( name ) `) But how do I know this works every time when…
dshukertjr
  • 15,244
  • 11
  • 57
  • 94
16
votes
3 answers

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 Supabase?
dshukertjr
  • 15,244
  • 11
  • 57
  • 94
14
votes
1 answer

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/index.js Module not found: Can't resolve 'encoding'…
Max Silva
  • 477
  • 1
  • 7
  • 15
14
votes
2 answers

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 it via the frontend in an easier manner?
Sumit Ghosh
  • 1,033
  • 10
  • 29
13
votes
1 answer

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 insert book and get ID - Second API call to insert…
Bojan Krkic
  • 349
  • 3
  • 10
8
votes
3 answers

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 REFERENCES car(id), name TEXT ); I want to…
Max
  • 754
  • 8
  • 24
7
votes
1 answer

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: bouncer config error 0:…
steve238
  • 831
  • 1
  • 10
  • 19
7
votes
3 answers

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 to delete the Comments as well. Something like…
Sventies
  • 2,314
  • 1
  • 28
  • 44
6
votes
1 answer

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": "Created" } For columns that are Is Identity, it automatically assigns a…
Jingles
  • 875
  • 1
  • 10
  • 31
6
votes
1 answer

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": "2022-03-02T11:01:11+00:00", "played_at":…
vikingsteve
  • 38,481
  • 23
  • 112
  • 156
5
votes
1 answer

`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 login supabase init When I go to run supabase…
Azarath
  • 81
  • 6
5
votes
2 answers

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 there's no apparent feature to extract the entire…
risky last
  • 385
  • 4
  • 12
5
votes
2 answers

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: jammy when I run Prisma push and generate command in…
5
votes
1 answer

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 Supabase Table into several input fields as…
Reuben Rapose
  • 157
  • 2
  • 8
5
votes
2 answers

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 - settings will be saved in "settings" table with…
1
2 3
21 22