This is an example/starter using the following stack:
- NestJS
- Fastity
- Custom logger (pino with pino-pretty)
- Custom logger with possibility to add request id to the logs
- Loading and processing environment variables with Configuration
- Tests with Vitest
- Drizzle ORM
- Multiple schemas
- Custom logger (with interpolated queries)
- Example with reusable DAO
abstract.dao
shows a way to abstract some reusable Drizzle ORM queries, e.g.,- getAll - get all entries for a specific entity
- getById - get entries with specific id
- getBySingleKey - get all entries with a specific value for the given key
- PostgresSQL
It's an attempt (simple and concise) to show how to create multiple schemas using Drizzle ORM. Currently, Drizzle doesn't provide an easy way to do so.
Why do we want multiple schemas?
Sometimes for testing purposes we want to have the following schemas
test1
- Schema for test1test2
- Schema for test2- ...
testN
- Schema for testN
This way, we can run each test against a specific schema, so that, the tests are contained.
This might also be useful for a multi-tenant approach.
npm i
env DB_USER="drizzle-orm" env DB_PASSWORD="pass" env DB_HOST_NAME="localhost" env DB_PORT="5432" env DB_NAME="drizzle-orm" env DB_SCHEMA_NAME="schema_1" npm run start
Afterwards, open the following URL http://localhost:7979/api/jobs
To have a better understanding about how migrations are set up, please see migrations README