Overview
Get started with the database.
We're using Drizzle ORM to interact with the database. It basically adds a little layer of abstraction between our code and the database.
If you know SQL, you know Drizzle.
For the database we're leveraging PostgreSQL (which comes directly from Supabase), but you could use any other database that Drizzle ORM supports (basically any SQL database e.g. MySQL, SQLite, etc.).
Why Drizzle ORM?
Drizzle ORM is a powerful tool that allows you to interact with the database in a type-safe manner. It ships with 0 (!) dependencies and is designed to be fast and easy to use.
Setup
To start interacting with the database you first need to ensure that your database instance is up and running.
For local development we recommend using the Supabase Local container.
You can start the container with the following command:
This will start the database container and initialize the database with the latest schema.
Where is DATABASE_URL?
DATABASE_URL
is a connection string that is used to connect to the database. When the command will finish it will be displayed in the console.
Then, you need to set DATABASE_URL
environment variable in root .env.local
file.
You're ready to go! 🥳
Studio
TurboStarter provides you also with an interactive UI where you can explore your database and test queries called Studio.
To run the Studio, you can use the following command:
This will start the Studio on https://local.drizzle.studio.
Next steps
- Update schema - learn about schema and how to update it.
- Generate & run migrations - migrate your changes to the database.
- Initialize client - initialize the database client and start interacting with the database.
Last updated on