Database
Last updated
Last updated
Shipped comes with a database ORM that makes it extremely easy to configure a database and interact with it (query, insert, update, delete) — Prisma.
Prisma supports multiple databases, PostgreSQL, MySQL, MariaDB, MongoDB, and others (full list here).
I always go with Postgres, because it's one of the best SQL databases in the market, open source, very popular, and very stable.
You can create a Postgres database for free using Supabase.
But these are other popular services to create a SQL database (Postgres or MySQL):
I usually go with DigitalOcean, because of its ease of use.
If you prefer a NoSQL database instead, go with MongoDB. You can create a managed MongoDB instance in the cloud using MongoDB Atlas.
Create the database using your favorite service, and get the connection string.
For Postgres, it is a string with this format
If you use the Supabase Postgres, take the database connection string string way.
Go to Supabase and select your project.
Go to Home.
Click on the button "Connect".
Click on the tab "ORMs"
Paste DATABASE_URL and DIRECT_URL to your .env
Paste the schema.prisma
values into your local file
Paste it into the .env
file as the value for the variable DATABASE_URL
The database schema (tables and columns) is defined in the file prisma/schema.prisma
and Shipped already provides the base tables to handle authentication there.
Open prisma/schema.prisma
and set provider = "postgresql"
.
Here's the list of provider values:
PostgreSQL
postgresql
MySQL
mysql
MariaDB
mysql
SQLite
sqlite
Microsoft SQL Server
sqlserver
MongoDB
mongodb
CockroachDB
cockroachdb
To initiate your database, open a terminal, go to the Shipped folder, and run
Now the database is ready to be used.
If you see this message, you are ready!
To execute query, insert, update, delete on the database, follow this pattern.