`npm install -g cws-ts-generator`
npm install cws-ts-generator
npm install -g cws-ts-generator
- This script will create a dir named output in your root directory
- Inside output will be a dir: persistent-classes, a file: [app-name].generated.d.ts, and a file: Orm.ts
###CLI:
cws-ts-generator -d
###Programmatically:
``javascript
through
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 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);
})