Drizzle β
Drizzle ORM is a headless TypeScript ORM with a head π²
It looks and feels simple, performs on day 1000 of your project, lets you do things your way, and is there when you need it.
Itβs the only ORM with both relational and SQL-like query APIs, providing you best of both worlds when it comes to accessing your relational data. Drizzle is lightweight, performant, typesafe, non lactose, gluten-free, sober, flexible and serverless-ready by design. Drizzle is not just a library, itβs an experience π€©
With Drizzle Pergel Module β
- π Lightweight and performant
- π Typesafe and flexible
- π Autochange schema folder in database
- ποΈ Autoimport and export schema, seeds, storage
- π Smart seed manamanagement
- π CLI support
Installation β
Step 1: Install β
Install pergel nuxt module. here
Step 2: Configuration β
// https://nuxt.com/docs/api/configuration-nuxt-config#projects
export default defineNuxtConfig({
modules: [
'pergel/nuxt',
],
pergel: {
projects: {
changeName: {
drizzle: true,
// ... other modules
}
},
},
})
changeName
changeName
is the name of your project. Please change it to your project name.
Step 3: Generate Type and Pergel folders/files β
$ pnpm nuxt prepare
$ npm nuxt prepare
$ yarn nuxt prepare
$ bun nuxt prepare
Step 4: Install Dependencies/DevDependencies β
Auto install dependencies and devDependencies for the project.
$ pnpm pergel install
$ npm pergel install
$ yarn pergel install
$ bun pergel install
Step 5: Environment Variables β
pergel/.env.example
file will be created. You need to copy what belongs to drizzle in the envs and move root.
Lifecycle β
Structure β
pergel/
ββ .env.example
ββ merged-package.json
ββ changeName.docker-compose.yml
ββ README.json
server/
ββ [drizzle-changeName]/
β ββ schema/
β β ββ [names].ts
β β ββ index.ts
β ββ seeds/
β β ββ devDrop.ts
β β ββ devMigration.ts
β β ββ devSeed.ts
β β ββ seed1.ts
β ββ storage/
β β ββ index.ts
β β ββ [names].ts
| ββ core.ts
β ββ drizzle.config.js
β ββ index.ts
.env.example β
All env settings and how to type will be automatically generated by the Pergel. You need to copy what belongs to drizzle in the envs and move root.
changeName.docker-compose.yml β
All the tools needed for the project are automatically created in the docker. The database for Drizzle will be added.
$ docker-compose up
server β
drizzle-changeName β
This is the main folder for the Drizzle. It contains the schema, seeds, storage, and drizzle.config.js.
schema β
This is the table schema. It is automatically generated from the database schema. server/drizzle-changeName/index.ts
is automatically added to the server.
const table = changeNameTables.
Β
Β
Β
seeds β
All env and sample code structures required for seed have been added. You can customize the code inside as you like.
WARNING
Do not change the file names here. You can just add seed1 and new seed2 etc and change them. Because this part is CLI dependent.
storage β
This is the storage folder. It is automatically generated from the database schema. server/drizzle-changeName/index.ts
is automatically added to the server.
const {
auth,
// ...
} = changeNameDrizzleStorage()
auth.
Β
Β
Β
drizzle.config.js β
This is the main configuration file for the Drizzle. The Pergel CLI uses it automatically.
Go to the Drizzle Pergel CLI here
Wizardry β
As the code in the
server/drizzle-changeName/schema/**
changes, the database is automatically changed. This does not create migration, it instantly changes the database.server/drizzle-changeName/*.ts
All exported files are automatically imported and can be used everywhere without importing. only ts files at root are valid.