Is an ORM
Commands:
drizzle-kit push
creates the database based on the given schema.
Add drizzle to project
npm i drizzle-orm pg dotenv
npm i -D drizzle-kit tsx @types/pg
Use PNPM to save disk space.
Basics
Getting all entries, not just one:
.all();
Schema generation & migration
- drizzle-kit generate will create migration file based on current schema It will not change the actual DB
- drizzle-kit migrate will apply SQL migration to the database
- drizzle-kit push will apply the current schema to the DB without creating a migration file
Pushing
Using npm run db:push
(usually) you can push the schema defined in your TypeScript with Drizzle to the production or development server. This will alter the structure of the DB, so be careful.