DirectoryFast
  • 🚀Get Started
  • 🔤Tutorials
    • Bring me to life!
    • How it's structured?
    • Make it yours
    • Bonus
  • 🛠️Features
    • AI
      • AI URL Scanner & Scan Jobs
    • Analytics
    • Authentication
    • API
      • Protected Endpoints
    • Blog
    • Database
    • Emails
    • Error Pages
    • Icons
    • Payments
    • Private Pages
    • SEO
  • 📦General Components
    • Shadcn/ui Components
    • Navbar
    • Footer
    • SignIn Modal
    • Hero Section
    • Social Proof
    • Collections Social Proof
    • Featured Section
    • Latest Collections Section
    • Latest Products Section
    • Recommended Section
  • 📦Directory Components
    • Product Card
    • Collection Card
    • Product Note
    • Search Bar
    • Tags
    • Product Options Toggle
    • Combobox
    • Multi-Combobox
    • Submit Product
    • Feature Product
    • Manage Note
    • Manage Collection
    • Dashboard Tables
  • ⛓️Links
    • GitHub Repository
    • Support
Powered by GitBook
On this page
  • Setup
  • Database Init
  • Database Queries
  1. Features

Database

Prisma will allow you to query the database with ease using Javascript/Typescript

PreviousBlogNextEmails

Last updated 11 months ago

You can use any SQL database but I recommend Postgres.

Fell free to use any provider you like:

  • Your own server!

Setup

  1. Get your URI (a string starting with "postgres:")

postgres://user:password@postgres:5432/dbname
  1. Paste it to your .env:

.env
# Database URL
POSTGRES_URL="postgres://user:password@postgres:6543/dbname?pgbouncer=true&connection_limit=1"
POSTGRES_URL_NON_POOLING=""postgres://user:password@postgres:5432/dbname"

Prefer a Pooling URL (PORT 6543) for Serverless environnements.

If you don't have a pooling URL, fill the 2 lines with your standard URI (PORT 5432)

Database Init

Simply run these commands:

Terminal
npx prisma generate
npx prisma migrate dev --skip-seed # push the schema to the database without seeds

Database Queries

Prisma greatly simplify the database queries, here's an example:

const product = await prisma.product.findUnique({
    where: {
      slug: params.slug,
    },
    include: {
      ratings: true,
      category: true,
      collections: {
        include: {
          user: true,
          products: true,
        },
      },
    },
  });

Learn more by checking the . 📖

🛠️
Supabase
NeonDB
official Prisma documentation