Library for a complete solution using knex and database first
I can't take code-first anymore
npm i knexdl
- you need to have a .env file with the connection string
npx knexdl introspect <env> <model>
- options:
- env > environment name containing connection string
- model > model name output
- -e, --env > path to environments file
npx knexdl introspect DATABASE_URL app -e /var/enviroments/.env
import knex from 'knex'
import type { AppModels } from 'knexdl/app'
const myModel = knex({ ...knexConfiguration }) as unknown as AppModels
export default myModel
- [x] Auto generate MySql types from database for ts
- [x] Introspect multiple databases fully typed
- [ ] Add defaults for Json fields or any column
- [ ] Auto generate PostgreSql types from database
- [ ] Integration with commonjs
- [ ] Auto generate models for each table