knexdl
TypeScript icon, indicating that this package has built-in type declarations

1.0.7 • Public • Published

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

  • [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

Package Sidebar

Install

npm i knexdl

Weekly Downloads

0

Version

1.0.7

License

MIT

Unpacked Size

25.9 kB

Total Files

15

Last publish

Collaborators

  • mathec-x