1.0.7 • Published 2 years ago
knexdl v1.0.7
knexdl
Library for a complete solution using knex and database first
motivation
I can't take code-first anymore
Installation
npm i knexdl
How to Use
- you need to have a .env file with the connection string
introspect
npx knexdl introspect <env> <model>
- options:
- env > environment name containing connection string
- model > model name output
- -e, --env > path to environments file
example
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
Future
- Auto generate MySql types from database for ts
- 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