2017-03-23 19:52:39 +00:00
|
|
|
# typeorm-model-generator
|
2017-12-27 21:48:03 +00:00
|
|
|
|
|
|
|
[![Greenkeeper badge](https://badges.greenkeeper.io/Kononnable/typeorm-model-generator.svg)](https://greenkeeper.io/)
|
2017-05-03 19:28:58 +00:00
|
|
|
[![Build Status](https://travis-ci.org/Kononnable/typeorm-model-generator.svg?branch=master)](https://travis-ci.org/Kononnable/typeorm-model-generator)
|
|
|
|
[![npm version](https://badge.fury.io/js/typeorm-model-generator.svg)](https://badge.fury.io/js/typeorm-model-generator)
|
2017-05-03 20:05:49 +00:00
|
|
|
[![codecov](https://codecov.io/gh/Kononnable/typeorm-model-generator/branch/master/graph/badge.svg)](https://codecov.io/gh/Kononnable/typeorm-model-generator)
|
2017-05-03 19:28:58 +00:00
|
|
|
|
2018-01-16 22:07:35 +00:00
|
|
|
Generates models for TypeORM from existing databases.
|
2017-07-20 21:16:55 +00:00
|
|
|
Suported db engines:
|
|
|
|
* Microsoft SQL Server
|
|
|
|
* PostgreSQL
|
2017-08-14 18:28:03 +00:00
|
|
|
* MySQL
|
|
|
|
* MariaDB
|
2018-04-18 20:15:07 +00:00
|
|
|
* Oracle Database
|
2018-05-03 19:52:57 +00:00
|
|
|
* SQLite
|
2017-07-20 21:16:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
## Installation
|
|
|
|
### Global module
|
|
|
|
To install module globally simply type `npm i -g typeorm-model-generator` in your console.
|
|
|
|
### Npx way
|
|
|
|
Thanks to npx you can use npm modules without polluting global installs. So nothing to do here :)
|
2018-01-16 22:07:35 +00:00
|
|
|
>To use `npx` you need to use npm at version at least 5.2.0. Try updating your npm by `npm i -g npm`
|
2017-07-20 21:16:55 +00:00
|
|
|
## Usage
|
|
|
|
|
|
|
|
```shell
|
|
|
|
Usage: typeorm-model-generator -h <host> -d <database> -p [port] -u <user> -x
|
|
|
|
[password] -e [engine]
|
|
|
|
|
|
|
|
Options:
|
2018-05-03 19:52:57 +00:00
|
|
|
--help Show help [boolean]
|
|
|
|
--version Show version number [boolean]
|
|
|
|
-h, --host IP adress/Hostname for database server. [required]
|
|
|
|
-d, --database Database name. [required]
|
|
|
|
-u, --user Username for database server. [required]
|
|
|
|
-x, --pass Password for database server. [default: ""]
|
|
|
|
-p, --port Port number for database server.
|
|
|
|
-e, --engine Database engine.
|
|
|
|
[choices: "mssql", "postgres", "mysql", "mariadb", "oracle", "sqlite"]
|
|
|
|
[default: "mssql"]
|
|
|
|
-o, --output Where to place generated models.
|
|
|
|
[default: "Z:\Repos\typeorm-model-generator\output"]
|
|
|
|
-s, --schema Schema name to create model from. Only for mssql and
|
|
|
|
postgres.
|
|
|
|
--ssl [boolean] [default: false]
|
|
|
|
--noConfig Doesn't create tsconfig.json and ormconfig.json
|
2018-01-16 22:07:35 +00:00
|
|
|
[boolean] [default: false]
|
2018-05-03 19:52:57 +00:00
|
|
|
--cf, --case-file Convert file names to specified case
|
2018-01-20 00:30:47 +00:00
|
|
|
[choices: "pascal", "param", "camel", "none"] [default: "none"]
|
2018-05-03 19:52:57 +00:00
|
|
|
--ce, --case-entity Convert class names to specified case
|
2018-01-20 00:30:47 +00:00
|
|
|
[choices: "pascal", "camel", "none"] [default: "none"]
|
|
|
|
--cp, --case-property Convert property names to specified case
|
|
|
|
[choices: "pascal", "camel", "none"] [default: "none"]
|
2018-05-03 19:52:57 +00:00
|
|
|
--lazy Generate lazy relations [boolean] [default: false]
|
2017-07-20 21:16:55 +00:00
|
|
|
```
|
|
|
|
### Examples
|
|
|
|
|
|
|
|
* Creating model from local MSSQL database
|
2018-01-16 22:07:35 +00:00
|
|
|
* Global module
|
2017-07-20 21:16:55 +00:00
|
|
|
```
|
2018-01-21 11:25:10 +00:00
|
|
|
typeorm-model-generator -h localhost -d tempdb -u sa -x !Passw0rd -e mssql -o .
|
2017-07-20 21:16:55 +00:00
|
|
|
````
|
2018-01-16 22:07:35 +00:00
|
|
|
* Npx Way
|
2017-07-20 21:16:55 +00:00
|
|
|
```
|
2018-01-21 11:25:10 +00:00
|
|
|
npx typeorm-model-generator -h localhost -d tempdb -u sa -x !Passw0rd -e mssql -o .
|
2017-07-20 21:16:55 +00:00
|
|
|
````
|
2017-10-15 17:16:53 +00:00
|
|
|
* Creating model from local Postgres database, public schema with ssl connection
|
2018-01-16 22:07:35 +00:00
|
|
|
* Global module
|
2017-07-20 21:16:55 +00:00
|
|
|
```
|
2018-01-21 11:25:10 +00:00
|
|
|
typeorm-model-generator -h localhost -d postgres -u postgres -x !Passw0rd -e postgres -o . -s public --ssl
|
2017-07-20 21:16:55 +00:00
|
|
|
````
|
2018-01-16 22:07:35 +00:00
|
|
|
* Npx Way
|
2017-07-20 21:16:55 +00:00
|
|
|
```
|
2018-01-21 11:25:10 +00:00
|
|
|
npx typeorm-model-generator -h localhost -d postgres -u postgres -x !Passw0rd -e postgres -o . -s public --ssl
|
2018-01-16 22:07:35 +00:00
|
|
|
````
|