1.0.2 • Published 5 years ago
tsmg v1.0.2
tsmg (Typescript model generator)
A simple cli to generate typescript interfaces, types or classes based on database tables. Currently only supports mysql.
Install
Also make sure the nessacery database drivers are also installed.
npm i -g tsmgUsage
Pass a configuration file to parse. Consult example-config.json and parameters stated below.
tsmg -c config.jsonConfig parameters
drivera string with the database driver to use. Currently, only supportsmysql.driverOptionsan object with the connection parameters to be passed to the connection object.dira string with the default directory to place generated models, can be overridden for specific tables.defaultDba string with the default database to use, can be overridden for specific tables.defaultTypea string withinterface,classortypeto be generated by default.defaultSuffixa suffix to be appended to the file names.defaultConnectora string with a connector to use between the suffix and the main name of the file.tabSizedefault is 4.casethe case to use while naming models, one of:camel,pascalorsnake. Default:camel.renameClassToCaseboolean to rename tables in other naming nomenclatures into the specifiedcase.renameAttributeToCaseboolean to rename attributes in the models into the specifiedcase.setNullAsOptionalboolean to uses?:for null attributes from the table in the model.dateTimeAsDateboolean to type mysqldatettimefields as javascriptDateobjects.dateAsDateboolean to type mysqldatefields as javascriptDateobjects.reWriteboolean to truncate and use any files when generating models.modelViewsboolean to include sql views when generating models.entireDatabaseboolean to generate models for all the tables in the given database,tablesis ignored.classOptionsdefault options to use when generating classes.constructorboolean to generate a default constructor for the classsqlCRUDboolean to generate sql CRUD functions for the class (Not yet implemented).
tablesan array of objects or strings with the tables to generate models for.- accepts a string which is a table's name.
- An object:
typeoverride.suffixoverride.nameoverride.databaseoverride.constructoroverride.sqlCRUDoverride.omitan array of string or regex to omit attributes from the given table matching the filters.