1.0.13 • Published 5 months ago

database-to-types v1.0.13

Weekly downloads
-
License
ISC
Repository
github
Last release
5 months ago

Mysql to Typescript interfaces

alt

Lib to help conver a mysql schema to typescript interfaces

Installation

$ npm i database-to-types

how to use it

  • create a file called conection-sql-ts.json in the root of the project with the following content
{
  "host": "localhost", # host of the database
  "user": "user", # user of the database
  "password": "1234", #   password of the database
  "database": "db", # database name
  "port": 3306, # port of the database
  "options": {
    "prefix": "DB_", # prefix of the interface , if your table name is "users" the interface will be named DB_users
    "path": "./DB_new.d.ts" # path of the interface file that will be created
  }
}
  • add the following script to your package.json
"scripts": {
  "sync-db": "sync-db"
}
  • run the script
$ npm run sync-db

Globally use

  • install the package globally
$ npm i -g database-to-types
  • run the following command

  • replace the names of the database, user, password, host and port with the ones of your database

$ npx sync-db -s mysql://username:password@host:port/database

For example

$ npx sync-db -s mysql://user123:password123@localhost:3306/database123

options args

optiondescriptiondefault
-sdatabase confignone
-fpath to the interface file./interfaces.d.ts
-pprefix of the interfacenone

If it helps you, you can give me a star on GitHub 😀

1.0.13

5 months ago

1.0.9

5 months ago

1.0.8

5 months ago

1.0.7

5 months ago

1.0.6

5 months ago

1.0.11

5 months ago

1.0.10

5 months ago

1.0.12

5 months ago

1.0.5

5 months ago

1.0.4

5 months ago

1.0.3

5 months ago

1.0.2

5 months ago

1.0.1

5 months ago

1.0.0

5 months ago