cli-typecarver
v1.0.43
Published
<p align="center"> <img src="./typecaver.png" width="230" alt="TypeCaver Logo"> </p>
Downloads
27
Readme
CLI Tool to generate TypeScript interfaces from a MySQL database schema.
- Tool created using the lib database-to-interfaces to generate TypeScript interfaces from a MySQL database schema.
How to use
install the dependencies globally:
npm install -g cli-typecarvercreate a configuration file
configDatabase.configin the root of your project with the following content:port: 3306 host: localhost user: root password: 1234 database: midb filename: ./interfacesdb.ts filepath: ./a/aditionally, you can use the
create-configflag to create a default configuration file like this:npx get-database-interfaces create-configrun the tool in the same directory as the configuration file:
npx get-database-interfaces
if your configuration is correct , you will see the following output:
Configuration file | content 🧾
port: the port of the MySQL server (default: 3306)host: the host of the MySQL server (default: localhost)user: the user to connect to the MySQL server (default: root)password: the password to connect to the MySQL server (default: empty)database: the name of the database to connect to (default: empty)filename: the name of the file where the interfaces will be generated (default: interfaces)filepath: the path where the file will be generated (default: ./)prefix: the prefix to add to the interfaces (default: empty) , for example 'DB_' will generate interfaces likeDB_User,DB_Product, etc.dbType: the type of database to connect to (default: mysql) , currently only supportsmysqlandpostgresql.
Help ⛑️
- you can also use the template file
configDatabase.config.templateto create your own configuration file., just remove the.templateextension and fill in the values.
