Skip to content

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 ​

ts
// 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 ​

sh
$ pnpm nuxt prepare
sh
$ npm nuxt prepare
sh
$ yarn nuxt prepare
sh
$ bun nuxt prepare

Step 4: Install Dependencies/DevDependencies ​

Auto install dependencies and devDependencies for the project.

sh
$ pnpm pergel install
sh
$ npm pergel install
sh
$ yarn pergel install
sh
$ 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.

sh
$ 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.

ts

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.

ts

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 ​

  1. 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.

  2. server/drizzle-changeName/*.ts All exported files are automatically imported and can be used everywhere without importing. only ts files at root are valid.

Released under the MIT License.