Shipped
HomeContacts
  • Get started
  • 📚Tutorials
    • Make a waiting list
    • Launch a pre-sale
    • Build a SaaS
    • Create your store on Lemon Squeezy
  • 🟩Features
    • AI Services
    • Affiliate Program
    • Analytics
    • Authentication
      • MailChimp
      • Loops
      • AWS SES
      • SendGrid
      • Supabase Auth
        • Supabase Authentication Flow
        • Supabase Magic Link
        • Supabase Email & Password
        • Supabase Login with Google
    • API endpoints
      • 🛡️Authenticated API
    • Blog
    • Customer support
    • Chrome Extension
    • Dark mode
    • Database
      • Update your database
      • MongoDB
    • Emails
    • Error pages
    • Icons
    • Onboarding
    • Payments
      • Lemon Squeezy
        • Subscriptions
        • One-time purchase
        • Test mode
      • Stripe
    • Private pages
    • SEO
    • shadcn/ui
    • Supabase
    • Workspace / Organizations
  • 📦Components
    • AccountMenu
    • CtaBox
    • DarkModeSwitch
    • Explainer video
    • FAQ
    • Features
    • Footer
    • Header
    • Hero
    • Lifetime
    • Pricing
    • Sales Notification
    • Secondary Sidebar Pages
    • Sidebar
    • Tabs
    • Testimonials
    • Waitlist
    • WebAppPage
  • 🚀Deployment
  • ✅Other
    • Configuration
    • Changelog widget
    • Favicon
    • Google Fonts
    • Sitemap
    • Theme
  • Updates
  • GitHub Repository
  • Support
Powered by GitBook
On this page
  • Setup
  • 1. Set the connection string
  • 2. Set the provider
  • 3. Initiate the database
  • Database operations

Was this helpful?

  1. Features

Database

PreviousDark modeNextUpdate your database

Last updated 6 months ago

Was this helpful?

Shipped comes with a database ORM that makes it extremely easy to configure a database and interact with it (query, insert, update, delete) — .

Prisma supports multiple databases, PostgreSQL, MySQL, MariaDB, MongoDB, and others ().

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 .

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 .

Setup

Create the database using your favorite service, and get the connection string.

For Postgres, it is a string with this format

postgresql://johndoe:randompassword@host:5432/mydb?schema=public

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

1. Set the connection string

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.

2. Set the provider

Open prisma/schema.prisma and set provider = "postgresql" .

Here's the list of provider values:

Database
Provider value

PostgreSQL

postgresql

MySQL

mysql

MariaDB

mysql

SQLite

sqlite

Microsoft SQL Server

sqlserver

MongoDB

mongodb

CockroachDB

cockroachdb

3. Initiate the database

To initiate your database, open a terminal, go to the Shipped folder, and run

terminal
npm i # install all dependencies
npx prisma generate # initiate prisma
npx prisma db push # push the schema to the database

Now the database is ready to be used.

If you see this message, you are ready!

Database operations

To execute query, insert, update, delete on the database, follow this pattern.

example.ts
import { prismaClient } from "@/prisma/db";

const user = await prismaClient.user.findUnique({
  where: {
    email: "john@doe.com",
  },
});
🟩
⚙️
Prisma
full list here
Supabase
Digital Ocean
PlanetScale
Railway
AWS RDS
MongoDB Atlas