cws-ts-generator
v0.2.6
Published
`npm install -g cws-ts-generator`
Downloads
12
Readme
`npm install -g cws-ts-generator`
This script will create a dir named
output
in your root directoryInside
output
will be a dir:persistent-classes
, a file:[app-name].generated.d.ts
, and a file:Orm.ts
###CLI:cws-ts-generator -d <database> -u <user> -x <pass> -h <host> -d <dialect> -p <port> -s <skipTables> -t <throughTableIdentifiers> -r <shouldWriteRelations> -l <lookup tableName>,<lookup.start | null>,<lookup.end | null>
###Programmatically:
let cwsGenerate = require("cws-ts-generator");
const configOptions = {
config: {
db: "db name",
user: "user name",
pass: "password",
host: 'host',
dialect: "mssql | postgresql | mysql"
},
skipTables: ["tableToSkip", "otherTableToSkip", "etc"], // examples to skip
primaryKeyIdentifier: "yourPrimaryKeyForEveryTable", // common name of primary key
throughTableIdentifiers: ["2", "Map"], // these substrings are in every map table, so generator can properly map `through` tables
lookup: {
tableName: "Lookup", // for constant table that maps keys to value
start: "lkp", // start of created extra prop
end: "OidObject" // end of created extra prop
},
shouldWriteRelations: true // write extra props defining one:many, many:many relationships
};
// execute generator
cwsGenerate.exec(configOptions).then((res) => {
console.log(res);
})