drizzle-team / drizzle-team/drizzle-orm
1.0 beta: How to type drizzle?
- Dominant language
- TypeScript
- Stars
- 35.8k
- Forks
- 1.6k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 4
Description
### Enhancement hasn't been filed before.
- [x] I have verified this enhancement I'm about to request hasn't been suggested before.
### Describe the enhancement you want to request
Since Drizzle now wants `relations` rather than `schema`, how do we type the Drizzle object? I tried using `typeof relations` with no success, before it was working with `typeof schema`:
```ts
import { drizzle, type NeonDatabase } from 'drizzle-orm/neon-serverless';
import { relations } from '@myworkspace/db';
let db: NeonDatabase; // <- Doesnt work with relations
export const useDb = (): NeonDatabase => {
if (!db) {
db = drizzle('DATABASE_URL', {
relations,
casing: 'snake_case',
});
}
return db;
};
```
Contributor guide
Research direction
Start by inspecting the exported NeonDatabase type in drizzle-orm/neon-serverless and the relations export from @myworkspace/db. Compare its generic parameters with the drizzle(...) call using relations and casing: 'snake_case'. Done means the supported TypeScript typing for this 1.0 beta pattern is identified and documented with a working example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql, typescript
- Domain
- backend, databases
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100