Formatting existing code
This commit is contained in:
parent
a07f347e4b
commit
fe17e484ce
52
.travis.yml
52
.travis.yml
@ -1,32 +1,36 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- stable
|
||||
- 8
|
||||
- 6
|
||||
- stable
|
||||
- 8
|
||||
- 6
|
||||
sudo: required
|
||||
services:
|
||||
- docker
|
||||
- docker
|
||||
env:
|
||||
matrix:
|
||||
- POSTGRES_Skip=0 POSTGRES_Host=localhost POSTGRES_Port=5432 POSTGRES_Username=postgres
|
||||
POSTGRES_Password=!Passw0rd POSTGRES_Database=typeorm_mg POSTGRES_SSL=0 MYSQL_Skip=0
|
||||
MYSQL_Host=localhost MYSQL_Port=3306 MYSQL_Username=root MYSQL_Password=!Passw0rd
|
||||
MYSQL_Database=typeorm_mg MYSQL_SSL=1 MARIADB_Skip=0 MARIADB_Host=localhost MARIADB_Port=3307
|
||||
MARIADB_Username=root MARIADB_Password=!Passw0rd MARIADB_Database=typeorm_mg MARIADB_SSL=0
|
||||
global:
|
||||
secure: Xj6wO8aghAhi6nvBI/HTtW9mIq9xfigIQfCC7ZkgAcqS4Oe3ba+7A5pCJq6Fxndadc6Bg1bZ3BGCH3Upf/Yv3zCFybsk43LwwXPJoG9gCrva/me7Sd+ws30EcD2dsKbvjZqNYai/XdrhzJY+KlxWvS/g3N/puBNffcU5hteo1zllxakQIAiavJ64D4g+Th8LSytmb2qDDToSsCxXkzNSutaKgZSf6T8QCWzcl0NCZkl69s9kX7L5335HVBD9lR/EKFC4wqHQjryCDRAyNRvItZRNlTPqgOI8lvcTsH9zKozDwEz7h/zcLebbY/+YTsLB5pb2sa62tkQE0x24TG7bLxujQShEQZU8itkRSV+w6+0JpBHQPlSUppkQJBNGKao7GaO/Eix4mSyvHkeECmTWDtEpBGWERYLqCKGe2Nj3BfcA2Ue6pjz9CX8wnrCbx53j6be3M/g/gcx7fbJbX3P95yc1CWAaR+tJKlP38rTcyo+o+Db1Ft0pzRJyZGmkGGPnCj6LxWYSmVqumLYDyqAMBDcQYuVwaKaTsJtU/2OBb3+zjKmWivV+19SXBqILvFbLv9IYLavpMr9OAwDGcJu0+mF+VCjGkZTlBxWJ53PmCoIJ6Qx/5o67LsCYL4L/hugNETlOEEKwe/k1mBraYWB0jI3mBUCV0d8J5P+ZQhwIZo4=
|
||||
matrix:
|
||||
- >-
|
||||
POSTGRES_Skip=0 POSTGRES_Host=localhost POSTGRES_Port=5432
|
||||
POSTGRES_Username=postgres POSTGRES_Password=!Passw0rd
|
||||
POSTGRES_Database=typeorm_mg POSTGRES_SSL=0 MYSQL_Skip=0
|
||||
MYSQL_Host=localhost MYSQL_Port=3306 MYSQL_Username=root
|
||||
MYSQL_Password=!Passw0rd MYSQL_Database=typeorm_mg MYSQL_SSL=1
|
||||
MARIADB_Skip=0 MARIADB_Host=localhost MARIADB_Port=3307
|
||||
MARIADB_Username=root MARIADB_Password=!Passw0rd
|
||||
MARIADB_Database=typeorm_mg MARIADB_SSL=0
|
||||
global:
|
||||
secure: >-
|
||||
Xj6wO8aghAhi6nvBI/HTtW9mIq9xfigIQfCC7ZkgAcqS4Oe3ba+7A5pCJq6Fxndadc6Bg1bZ3BGCH3Upf/Yv3zCFybsk43LwwXPJoG9gCrva/me7Sd+ws30EcD2dsKbvjZqNYai/XdrhzJY+KlxWvS/g3N/puBNffcU5hteo1zllxakQIAiavJ64D4g+Th8LSytmb2qDDToSsCxXkzNSutaKgZSf6T8QCWzcl0NCZkl69s9kX7L5335HVBD9lR/EKFC4wqHQjryCDRAyNRvItZRNlTPqgOI8lvcTsH9zKozDwEz7h/zcLebbY/+YTsLB5pb2sa62tkQE0x24TG7bLxujQShEQZU8itkRSV+w6+0JpBHQPlSUppkQJBNGKao7GaO/Eix4mSyvHkeECmTWDtEpBGWERYLqCKGe2Nj3BfcA2Ue6pjz9CX8wnrCbx53j6be3M/g/gcx7fbJbX3P95yc1CWAaR+tJKlP38rTcyo+o+Db1Ft0pzRJyZGmkGGPnCj6LxWYSmVqumLYDyqAMBDcQYuVwaKaTsJtU/2OBb3+zjKmWivV+19SXBqILvFbLv9IYLavpMr9OAwDGcJu0+mF+VCjGkZTlBxWJ53PmCoIJ6Qx/5o67LsCYL4L/hugNETlOEEKwe/k1mBraYWB0jI3mBUCV0d8J5P+ZQhwIZo4=
|
||||
before_install:
|
||||
- sudo service mysql stop
|
||||
- sudo service postgresql stop
|
||||
- docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD"
|
||||
- docker-compose up -d
|
||||
- npm install -g npm@5
|
||||
- npm install -g greenkeeper-lockfile@1
|
||||
|
||||
- sudo service mysql stop
|
||||
- sudo service postgresql stop
|
||||
- docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD"
|
||||
- docker-compose up -d
|
||||
- npm install -g npm@5
|
||||
- npm install -g greenkeeper-lockfile@1
|
||||
before_script:
|
||||
- greenkeeper-lockfile-update
|
||||
- npm run typings-install
|
||||
- npm link typescript
|
||||
- tsc
|
||||
- greenkeeper-lockfile-update
|
||||
- npm run typings-install
|
||||
- npm link typescript
|
||||
- tsc
|
||||
after_script:
|
||||
- greenkeeper-lockfile-upload
|
||||
- greenkeeper-lockfile-upload
|
||||
|
20
codecov.yml
20
codecov.yml
@ -1,14 +1,14 @@
|
||||
parsers:
|
||||
javascript:
|
||||
enable_partials: yes
|
||||
javascript:
|
||||
enable_partials: yes
|
||||
comment:
|
||||
layout: diff
|
||||
behavior: default
|
||||
layout: diff
|
||||
behavior: default
|
||||
codecov:
|
||||
notify:
|
||||
require_ci_to_pass: no
|
||||
notify:
|
||||
require_ci_to_pass: no
|
||||
coverage:
|
||||
status:
|
||||
project:
|
||||
default:
|
||||
threshold: 5%
|
||||
status:
|
||||
project:
|
||||
default:
|
||||
threshold: 5%
|
||||
|
@ -47,4 +47,3 @@ services:
|
||||
# environment:
|
||||
# DB_SID: "ORCLCDB"
|
||||
# SYS_PASSWORD: "Oradoc_db1"
|
||||
|
@ -16,12 +16,12 @@ export class Engine {
|
||||
if (dbModel.entities.length > 0) {
|
||||
this.createModelFromMetadata(dbModel);
|
||||
} else {
|
||||
TomgUtils.LogFatalError('Tables not found in selected database. Skipping creation of typeorm model.',false);
|
||||
TomgUtils.LogFatalError('Tables not found in selected database. Skipping creation of typeorm model.', false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private async getEntitiesInfo(database: string, server: string, port: number, user: string, password: string, schemaName:string, ssl:boolean): Promise<DatabaseModel> {
|
||||
return await this.driver.GetDataFromServer(database, server, port, user, password,schemaName,ssl)
|
||||
private async getEntitiesInfo(database: string, server: string, port: number, user: string, password: string, schemaName: string, ssl: boolean): Promise<DatabaseModel> {
|
||||
return await this.driver.GetDataFromServer(database, server, port, user, password, schemaName, ssl)
|
||||
|
||||
}
|
||||
private createModelFromMetadata(databaseModel: DatabaseModel) {
|
||||
@ -38,10 +38,10 @@ export class Engine {
|
||||
});
|
||||
if (!fs.existsSync(entitesPath))
|
||||
fs.mkdirSync(entitesPath);
|
||||
let compliedTemplate = Handlebars.compile(template,{noEscape:true})
|
||||
let compliedTemplate = Handlebars.compile(template, { noEscape: true })
|
||||
databaseModel.entities.forEach(element => {
|
||||
let resultFilePath = path.resolve(entitesPath, element.EntityName + '.ts');
|
||||
let rendered =compliedTemplate(element)
|
||||
let rendered = compliedTemplate(element)
|
||||
fs.writeFileSync(resultFilePath, rendered, { encoding: 'UTF-8', flag: 'w' })
|
||||
});
|
||||
}
|
||||
@ -83,6 +83,6 @@ export interface EngineOptions {
|
||||
password: string,
|
||||
resultsPath: string,
|
||||
databaseType: string,
|
||||
schemaName:string,
|
||||
ssl:boolean
|
||||
schemaName: string,
|
||||
ssl: boolean
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
|
||||
import * as data from './../../package.json'
|
||||
export function LogFatalError(errText:string, isABug:boolean=true,errObject?:any) {
|
||||
let x = <any>data;
|
||||
export function LogFatalError(errText: string, isABug: boolean = true, errObject?: any) {
|
||||
let x = <any>data;
|
||||
console.error(`Fatal error occured.`)
|
||||
console.error(`${x.name}@${x.version} node@${process.version}`)
|
||||
console.error(`Fatal error occured in typeorm-model-generator.`)
|
||||
console.error(`If this is a bug please open an issue including this log on ${x.bugs.url}`)
|
||||
if (isABug&&!errObject) errObject=new Error().stack
|
||||
if (!!errObject) console.error(errObject)
|
||||
if (isABug && !errObject) errObject = new Error().stack
|
||||
if (!!errObject) console.error(errObject)
|
||||
process.abort()
|
||||
}
|
||||
|
@ -4,22 +4,22 @@ import { DatabaseModel } from './../models/DatabaseModel'
|
||||
* AbstractDriver
|
||||
*/
|
||||
export abstract class AbstractDriver {
|
||||
async GetDataFromServer(database: string, server: string, port: number, user: string, password: string, schema:string, ssl:boolean): Promise<DatabaseModel> {
|
||||
async GetDataFromServer(database: string, server: string, port: number, user: string, password: string, schema: string, ssl: boolean): Promise<DatabaseModel> {
|
||||
let dbModel = <DatabaseModel>{};
|
||||
await this.ConnectToServer(database, server, port, user, password,ssl);
|
||||
await this.ConnectToServer(database, server, port, user, password, ssl);
|
||||
dbModel.entities = await this.GetAllTables(schema);
|
||||
await this.GetCoulmnsFromEntity(dbModel.entities,schema);
|
||||
await this.GetIndexesFromEntity(dbModel.entities,schema);
|
||||
dbModel.entities = await this.GetRelations(dbModel.entities,schema);
|
||||
await this.GetCoulmnsFromEntity(dbModel.entities, schema);
|
||||
await this.GetIndexesFromEntity(dbModel.entities, schema);
|
||||
dbModel.entities = await this.GetRelations(dbModel.entities, schema);
|
||||
await this.DisconnectFromServer();
|
||||
this.FindPrimaryColumnsFromIndexes(dbModel)
|
||||
return dbModel;
|
||||
}
|
||||
abstract async ConnectToServer(database: string, server: string, port: number, user: string, password: string,ssl:boolean);
|
||||
abstract async GetAllTables(schema:string): Promise<EntityInfo[]>
|
||||
abstract async GetCoulmnsFromEntity(entities: EntityInfo[],schema:string): Promise<EntityInfo[]>;
|
||||
abstract async GetIndexesFromEntity(entities: EntityInfo[],schema:string): Promise<EntityInfo[]>;
|
||||
abstract async GetRelations(entities: EntityInfo[],schema:string): Promise<EntityInfo[]>;
|
||||
abstract async ConnectToServer(database: string, server: string, port: number, user: string, password: string, ssl: boolean);
|
||||
abstract async GetAllTables(schema: string): Promise<EntityInfo[]>
|
||||
abstract async GetCoulmnsFromEntity(entities: EntityInfo[], schema: string): Promise<EntityInfo[]>;
|
||||
abstract async GetIndexesFromEntity(entities: EntityInfo[], schema: string): Promise<EntityInfo[]>;
|
||||
abstract async GetRelations(entities: EntityInfo[], schema: string): Promise<EntityInfo[]>;
|
||||
abstract async FindPrimaryColumnsFromIndexes(dbModel: DatabaseModel);
|
||||
abstract async DisconnectFromServer();
|
||||
|
||||
@ -27,4 +27,4 @@ export abstract class AbstractDriver {
|
||||
abstract async DropDB(dbName: string);
|
||||
abstract async UseDB(dbName: string);
|
||||
abstract async CheckIfDBExists(dbName: string): Promise<boolean>;
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,6 @@ import { MysqlDriver } from './MysqlDriver';
|
||||
* MariaDb
|
||||
*/
|
||||
export class MariaDbDriver extends MysqlDriver {
|
||||
readonly EngineName:string = 'MariaDb'
|
||||
|
||||
}
|
||||
readonly EngineName: string = 'MariaDb'
|
||||
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ export class MssqlDriver extends AbstractDriver {
|
||||
dbModel.entities.forEach(entity => {
|
||||
let primaryIndex = entity.Indexes.find(v => v.isPrimaryKey);
|
||||
if (!primaryIndex) {
|
||||
TomgUtils.LogFatalError(`Table ${entity.EntityName} has no PK.`,false)
|
||||
TomgUtils.LogFatalError(`Table ${entity.EntityName} has no PK.`, false)
|
||||
return;
|
||||
}
|
||||
entity.Columns.forEach(col => {
|
||||
@ -361,15 +361,15 @@ order by
|
||||
isOneToMany = false;
|
||||
}
|
||||
let ownerRelation = new RelationInfo()
|
||||
let columnName = ownerEntity.EntityName.toLowerCase() + (isOneToMany ? 's' : '')
|
||||
let columnName = ownerEntity.EntityName.toLowerCase() + (isOneToMany ? 's' : '')
|
||||
if (referencedEntity.Columns.filter((filterVal) => {
|
||||
return filterVal.name == columnName;
|
||||
}).length>0){
|
||||
for (let i=2;i<=ownerEntity.Columns.length;i++){
|
||||
columnName = ownerEntity.EntityName.toLowerCase() + (isOneToMany ? 's' : '')+i.toString();
|
||||
}).length > 0) {
|
||||
for (let i = 2; i <= ownerEntity.Columns.length; i++) {
|
||||
columnName = ownerEntity.EntityName.toLowerCase() + (isOneToMany ? 's' : '') + i.toString();
|
||||
if (referencedEntity.Columns.filter((filterVal) => {
|
||||
return filterVal.name == columnName;
|
||||
}).length==0) break;
|
||||
}).length == 0) break;
|
||||
}
|
||||
}
|
||||
ownerRelation.actionOnDelete = relationTmp.actionOnDelete
|
||||
@ -442,7 +442,7 @@ order by
|
||||
resolve(true)
|
||||
}
|
||||
else {
|
||||
TomgUtils.LogFatalError('Error connecting to MSSQL Server.',false,err.message)
|
||||
TomgUtils.LogFatalError('Error connecting to MSSQL Server.', false, err.message)
|
||||
reject(err)
|
||||
}
|
||||
});
|
||||
|
@ -15,7 +15,7 @@ export class MysqlDriver extends AbstractDriver {
|
||||
dbModel.entities.forEach(entity => {
|
||||
let primaryIndex = entity.Indexes.find(v => v.isPrimaryKey);
|
||||
if (!primaryIndex) {
|
||||
TomgUtils.LogFatalError(`Table ${entity.EntityName} has no PK.`,false)
|
||||
TomgUtils.LogFatalError(`Table ${entity.EntityName} has no PK.`, false)
|
||||
return;
|
||||
}
|
||||
entity.Columns.forEach(col => {
|
||||
@ -334,7 +334,7 @@ export class MysqlDriver extends AbstractDriver {
|
||||
if (referencedEntity.Columns.filter((filterVal) => {
|
||||
return filterVal.name == columnName;
|
||||
}).length > 0) {
|
||||
for (let i=2;i<=ownerEntity.Columns.length;i++){
|
||||
for (let i = 2; i <= ownerEntity.Columns.length; i++) {
|
||||
columnName = ownerEntity.EntityName.toLowerCase() + (isOneToMany ? 's' : '') + i.toString();
|
||||
if (referencedEntity.Columns.filter((filterVal) => {
|
||||
return filterVal.name == columnName;
|
||||
@ -392,7 +392,7 @@ export class MysqlDriver extends AbstractDriver {
|
||||
resolve(true)
|
||||
}
|
||||
else {
|
||||
TomgUtils.LogFatalError(`Error disconnecting to ${this.EngineName} Server.`,false,err.message)
|
||||
TomgUtils.LogFatalError(`Error disconnecting to ${this.EngineName} Server.`, false, err.message)
|
||||
reject(err)
|
||||
}
|
||||
});
|
||||
@ -439,7 +439,7 @@ export class MysqlDriver extends AbstractDriver {
|
||||
resolve(true)
|
||||
}
|
||||
else {
|
||||
TomgUtils.LogFatalError(`Error connecting to ${this.EngineName} Server.`,false,err.message)
|
||||
TomgUtils.LogFatalError(`Error connecting to ${this.EngineName} Server.`, false, err.message)
|
||||
reject(err)
|
||||
}
|
||||
});
|
||||
|
@ -3,7 +3,7 @@ import { ColumnInfo } from './../models/ColumnInfo'
|
||||
import { EntityInfo } from './../models/EntityInfo'
|
||||
import { RelationInfo } from './../models/RelationInfo'
|
||||
import { DatabaseModel } from './../models/DatabaseModel'
|
||||
import {promisify} from 'util'
|
||||
import { promisify } from 'util'
|
||||
import { request } from 'https';
|
||||
import * as TomgUtils from './../Utils'
|
||||
|
||||
@ -11,14 +11,14 @@ import * as TomgUtils from './../Utils'
|
||||
/**
|
||||
* OracleDriver
|
||||
*/
|
||||
export class OracleDriver extends AbstractDriver {
|
||||
Oracle:any;
|
||||
export class OracleDriver extends AbstractDriver {
|
||||
Oracle: any;
|
||||
constructor() {
|
||||
super();
|
||||
try {
|
||||
this.Oracle= require('oracledb')
|
||||
this.Oracle = require('oracledb')
|
||||
} catch (error) {
|
||||
TomgUtils.LogFatalError('',false,error);
|
||||
TomgUtils.LogFatalError('', false, error);
|
||||
throw error;
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ import * as TomgUtils from './../Utils'
|
||||
dbModel.entities.forEach(entity => {
|
||||
let primaryIndex = entity.Indexes.find(v => v.isPrimaryKey);
|
||||
if (!primaryIndex) {
|
||||
TomgUtils.LogFatalError(`Table ${entity.EntityName} has no PK.`,false)
|
||||
TomgUtils.LogFatalError(`Table ${entity.EntityName} has no PK.`, false)
|
||||
return;
|
||||
}
|
||||
entity.Columns.forEach(col => {
|
||||
@ -43,7 +43,7 @@ import * as TomgUtils from './../Utils'
|
||||
|
||||
async GetAllTables(schema: string): Promise<EntityInfo[]> {
|
||||
|
||||
let response :any[][] = ( await this.Connection.execute(` SELECT TABLE_NAME FROM all_tables WHERE owner = (select user from dual)`)).rows!;
|
||||
let response: any[][] = (await this.Connection.execute(` SELECT TABLE_NAME FROM all_tables WHERE owner = (select user from dual)`)).rows!;
|
||||
let ret: EntityInfo[] = <EntityInfo[]>[];
|
||||
response.forEach((val) => {
|
||||
let ent: EntityInfo = new EntityInfo();
|
||||
@ -55,11 +55,11 @@ import * as TomgUtils from './../Utils'
|
||||
return ret;
|
||||
}
|
||||
async GetCoulmnsFromEntity(entities: EntityInfo[], schema: string): Promise<EntityInfo[]> {
|
||||
let response :any[][] = ( await this.Connection.execute(`SELECT TABLE_NAME, COLUMN_NAME, DATA_DEFAULT, NULLABLE, DATA_TYPE, DATA_LENGTH,
|
||||
let response: any[][] = (await this.Connection.execute(`SELECT TABLE_NAME, COLUMN_NAME, DATA_DEFAULT, NULLABLE, DATA_TYPE, DATA_LENGTH,
|
||||
DATA_PRECISION, DATA_SCALE, IDENTITY_COLUMN
|
||||
FROM USER_TAB_COLUMNS`)).rows!;
|
||||
|
||||
entities.forEach((ent) => {
|
||||
entities.forEach((ent) => {
|
||||
response.filter((filterVal) => {
|
||||
return filterVal[0] == ent.EntityName;
|
||||
}).forEach((resp) => {
|
||||
@ -90,7 +90,7 @@ import * as TomgUtils from './../Utils'
|
||||
return entities;
|
||||
}
|
||||
async GetIndexesFromEntity(entities: EntityInfo[], schema: string): Promise<EntityInfo[]> {
|
||||
let response :any[][] = ( await this.Connection.execute(`SELECT ind.TABLE_NAME, ind.INDEX_NAME, col.COLUMN_NAME,ind.UNIQUENESS, CASE WHEN uc.CONSTRAINT_NAME IS NULL THEN 0 ELSE 1 END
|
||||
let response: any[][] = (await this.Connection.execute(`SELECT ind.TABLE_NAME, ind.INDEX_NAME, col.COLUMN_NAME,ind.UNIQUENESS, CASE WHEN uc.CONSTRAINT_NAME IS NULL THEN 0 ELSE 1 END
|
||||
FROM USER_INDEXES ind
|
||||
JOIN USER_IND_COLUMNS col ON ind.INDEX_NAME=col.INDEX_NAME
|
||||
LEFT JOIN USER_CONSTRAINTS uc ON uc.INDEX_NAME = ind.INDEX_NAME
|
||||
@ -126,7 +126,7 @@ import * as TomgUtils from './../Utils'
|
||||
return entities;
|
||||
}
|
||||
async GetRelations(entities: EntityInfo[], schema: string): Promise<EntityInfo[]> {
|
||||
let response :any[][] = ( await this.Connection.execute(`select owner.TABLE_NAME ownTbl,ownCol.POSITION,ownCol.COLUMN_NAME,
|
||||
let response: any[][] = (await this.Connection.execute(`select owner.TABLE_NAME ownTbl,ownCol.POSITION,ownCol.COLUMN_NAME,
|
||||
child.TABLE_NAME,childCol.COLUMN_NAME,
|
||||
owner.DELETE_RULE,
|
||||
4,owner.CONSTRAINT_NAME
|
||||
@ -261,28 +261,28 @@ import * as TomgUtils from './../Utils'
|
||||
|
||||
private Connection: any/*Oracle.IConnection*/;
|
||||
async ConnectToServer(database: string, server: string, port: number, user: string, password: string, ssl: boolean) {
|
||||
let config: any/*Oracle.IConnectionAttributes*/ = {
|
||||
let config: any/*Oracle.IConnectionAttributes*/ = {
|
||||
user: user,
|
||||
password: password,
|
||||
// connectString: `${server}:${port}/ORCLCDB.localdomain/${database}`,
|
||||
connectString: `${server}:${port}/${database}`,
|
||||
externalAuth: ssl
|
||||
externalAuth: ssl
|
||||
}
|
||||
|
||||
|
||||
let that=this;
|
||||
let that = this;
|
||||
let promise = new Promise<boolean>(
|
||||
(resolve, reject) => {
|
||||
this.Oracle.getConnection(
|
||||
this.Oracle.getConnection(
|
||||
config,
|
||||
function (err, connection) {
|
||||
if (!err) {
|
||||
//Connection successfull
|
||||
that.Connection=connection
|
||||
that.Connection = connection
|
||||
resolve(true)
|
||||
}
|
||||
else {
|
||||
TomgUtils.LogFatalError('Error connecting to Oracle Server.',false,err.message)
|
||||
TomgUtils.LogFatalError('Error connecting to Oracle Server.', false, err.message)
|
||||
reject(err)
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ export class PostgresDriver extends AbstractDriver {
|
||||
dbModel.entities.forEach(entity => {
|
||||
let primaryIndex = entity.Indexes.find(v => v.isPrimaryKey);
|
||||
if (!primaryIndex) {
|
||||
TomgUtils.LogFatalError(`Table ${entity.EntityName} has no PK.`,false)
|
||||
TomgUtils.LogFatalError(`Table ${entity.EntityName} has no PK.`, false)
|
||||
return;
|
||||
}
|
||||
entity.Columns.forEach(col => {
|
||||
@ -389,15 +389,15 @@ export class PostgresDriver extends AbstractDriver {
|
||||
isOneToMany = false;
|
||||
}
|
||||
let ownerRelation = new RelationInfo()
|
||||
let columnName = ownerEntity.EntityName.toLowerCase() + (isOneToMany ? 's' : '')
|
||||
let columnName = ownerEntity.EntityName.toLowerCase() + (isOneToMany ? 's' : '')
|
||||
if (referencedEntity.Columns.filter((filterVal) => {
|
||||
return filterVal.name == columnName;
|
||||
}).length>0){
|
||||
for (let i=2;i<=ownerEntity.Columns.length;i++){
|
||||
columnName = ownerEntity.EntityName.toLowerCase() + (isOneToMany ? 's' : '')+i.toString();
|
||||
}).length > 0) {
|
||||
for (let i = 2; i <= ownerEntity.Columns.length; i++) {
|
||||
columnName = ownerEntity.EntityName.toLowerCase() + (isOneToMany ? 's' : '') + i.toString();
|
||||
if (referencedEntity.Columns.filter((filterVal) => {
|
||||
return filterVal.name == columnName;
|
||||
}).length==0) break;
|
||||
}).length == 0) break;
|
||||
}
|
||||
}
|
||||
ownerRelation.actionOnDelete = relationTmp.actionOnDelete
|
||||
@ -452,7 +452,7 @@ export class PostgresDriver extends AbstractDriver {
|
||||
resolve(true)
|
||||
}
|
||||
else {
|
||||
TomgUtils.LogFatalError('Error connecting to Postgres Server.',false,err.message)
|
||||
TomgUtils.LogFatalError('Error connecting to Postgres Server.', false, err.message)
|
||||
reject(err)
|
||||
}
|
||||
});
|
||||
@ -480,7 +480,7 @@ export class PostgresDriver extends AbstractDriver {
|
||||
resolve(true)
|
||||
}
|
||||
else {
|
||||
TomgUtils.LogFatalError('Error connecting to Postgres Server.',false,err.message)
|
||||
TomgUtils.LogFatalError('Error connecting to Postgres Server.', false, err.message)
|
||||
reject(err)
|
||||
}
|
||||
});
|
||||
|
@ -86,7 +86,7 @@ switch (argv.e) {
|
||||
standardPort = 1521;
|
||||
break;
|
||||
default:
|
||||
TomgUtils.LogFatalError('Database engine not recognized.',false)
|
||||
TomgUtils.LogFatalError('Database engine not recognized.', false)
|
||||
throw new Error('Database engine not recognized.');
|
||||
}
|
||||
|
||||
@ -107,4 +107,3 @@ console.log(`[${new Date().toLocaleTimeString()}] Starting creation of model cla
|
||||
engine.createModelFromDatabase().then(() => {
|
||||
console.info(`[${new Date().toLocaleTimeString()}] Typeorm model classes created.`)
|
||||
})
|
||||
|
||||
|
@ -22,5 +22,3 @@ export class ColumnInfo {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {EntityInfo} from './EntityInfo'
|
||||
import { EntityInfo } from './EntityInfo'
|
||||
export class DatabaseModel {
|
||||
entities: EntityInfo[];
|
||||
config: {
|
||||
@ -6,11 +6,11 @@ export class DatabaseModel {
|
||||
cascadeUpdate: boolean,
|
||||
cascadeRemove: boolean,
|
||||
}
|
||||
relationImports():any{
|
||||
let that=this;
|
||||
return function(text, render) {
|
||||
if ('l'!=render(text)) return `import {${render(text)}} from "./${render(text)}"`
|
||||
else return '';
|
||||
relationImports(): any {
|
||||
let that = this;
|
||||
return function (text, render) {
|
||||
if ('l' != render(text)) return `import {${render(text)}} from "./${render(text)}"`
|
||||
else return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,23 +8,23 @@ export class EntityInfo {
|
||||
Indexes: IndexInfo[];
|
||||
|
||||
relationImports(): any {
|
||||
var returnString = "";
|
||||
var imports: string[] = [];
|
||||
this.Columns.forEach((column) => {
|
||||
column.relations.forEach(
|
||||
(relation) => {
|
||||
if (this.EntityName!=relation.relatedTable)
|
||||
var returnString = "";
|
||||
var imports: string[] = [];
|
||||
this.Columns.forEach((column) => {
|
||||
column.relations.forEach(
|
||||
(relation) => {
|
||||
if (this.EntityName != relation.relatedTable)
|
||||
imports.push(relation.relatedTable);
|
||||
}
|
||||
)
|
||||
});
|
||||
imports.filter(function (elem, index, self) {
|
||||
return index == self.indexOf(elem);
|
||||
}).forEach((imp)=>{
|
||||
returnString+=`import {${imp}} from './${imp}'\n`
|
||||
})
|
||||
}
|
||||
)
|
||||
});
|
||||
imports.filter(function (elem, index, self) {
|
||||
return index == self.indexOf(elem);
|
||||
}).forEach((imp) => {
|
||||
returnString += `import {${imp}} from './${imp}'\n`
|
||||
})
|
||||
|
||||
return returnString;
|
||||
return returnString;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
interface IndexColumnInfo{
|
||||
name:string,
|
||||
interface IndexColumnInfo {
|
||||
name: string,
|
||||
//isDescending:boolean,
|
||||
// isIncludedColumn:boolean
|
||||
}
|
||||
}
|
||||
|
@ -2,8 +2,8 @@
|
||||
* IndexInfo
|
||||
*/
|
||||
interface IndexInfo {
|
||||
name:string,
|
||||
columns:IndexColumnInfo[],
|
||||
isUnique:boolean,
|
||||
isPrimaryKey:boolean,
|
||||
name: string,
|
||||
columns: IndexColumnInfo[],
|
||||
isUnique: boolean,
|
||||
isPrimaryKey: boolean,
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
export class RelationInfo { [x: string]: any;
|
||||
export class RelationInfo {
|
||||
[x: string]: any;
|
||||
|
||||
isOwner: boolean
|
||||
relationType: "OneToOne" | "OneToMany" | "ManyToOne"
|
||||
@ -13,4 +14,4 @@ export class RelationInfo { [x: string]: any;
|
||||
return this.relationType == "OneToMany"
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
interface RelationTempInfo{
|
||||
ownerTable:string,
|
||||
ownerColumnsNames:string[],
|
||||
referencedTable:string,
|
||||
referencedColumnsNames:string[],
|
||||
actionOnDelete:"RESTRICT"|"CASCADE"|"SET NULL"|"NO ACTION",
|
||||
actionOnUpdate:"RESTRICT"|"CASCADE"|"SET NULL"|"NO ACTION",
|
||||
object_id:number|string
|
||||
}
|
||||
interface RelationTempInfo {
|
||||
ownerTable: string,
|
||||
ownerColumnsNames: string[],
|
||||
referencedTable: string,
|
||||
referencedColumnsNames: string[],
|
||||
actionOnDelete: "RESTRICT" | "CASCADE" | "SET NULL" | "NO ACTION",
|
||||
actionOnUpdate: "RESTRICT" | "CASCADE" | "SET NULL" | "NO ACTION",
|
||||
object_id: number | string
|
||||
}
|
||||
|
@ -7,19 +7,19 @@ import { ColumnInfo } from './../../src/models/ColumnInfo'
|
||||
import { RelationInfo } from './../../src/models/RelationInfo'
|
||||
import { Table, IColumnMetadata } from "mssql";
|
||||
|
||||
class fakeResponse implements MSSQL.IResult<any> {
|
||||
recordsets: MSSQL.IRecordSet<any>[];
|
||||
recordset: MSSQL.IRecordSet<any>;
|
||||
rowsAffected: number[];
|
||||
output: { [key: string]: any; };
|
||||
|
||||
}
|
||||
class fakeRecordset extends Array<any> implements MSSQL.IRecordSet<any>{
|
||||
class fakeResponse implements MSSQL.IResult<any> {
|
||||
recordsets: MSSQL.IRecordSet<any>[];
|
||||
recordset: MSSQL.IRecordSet<any>;
|
||||
rowsAffected: number[];
|
||||
output: { [key: string]: any; };
|
||||
|
||||
}
|
||||
class fakeRecordset extends Array<any> implements MSSQL.IRecordSet<any>{
|
||||
columns: IColumnMetadata;
|
||||
toTable(): Table{
|
||||
toTable(): Table {
|
||||
return new Table();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
describe('MssqlDriver', function () {
|
||||
let driver: MssqlDriver
|
||||
@ -48,10 +48,10 @@ describe('MssqlDriver', function () {
|
||||
.returns(
|
||||
{
|
||||
query: (q) => {
|
||||
|
||||
let response=new fakeResponse();
|
||||
|
||||
response.recordset=new fakeRecordset();
|
||||
|
||||
let response = new fakeResponse();
|
||||
|
||||
response.recordset = new fakeRecordset();
|
||||
response.recordset.push({ TABLE_SCHEMA: 'schema', TABLE_NAME: 'name' })
|
||||
return response;
|
||||
}
|
||||
@ -71,13 +71,13 @@ describe('MssqlDriver', function () {
|
||||
.returns(
|
||||
{
|
||||
query: (q) => {
|
||||
let response=new fakeResponse();
|
||||
response.recordset=new fakeRecordset();
|
||||
let response = new fakeResponse();
|
||||
response.recordset = new fakeRecordset();
|
||||
response.recordset.push({
|
||||
TABLE_NAME: 'name', CHARACTER_MAXIMUM_LENGTH: 0,
|
||||
COLUMN_DEFAULT: 'a', COLUMN_NAME: 'name', DATA_TYPE: 'int',
|
||||
IS_NULLABLE: 'YES', NUMERIC_PRECISION: 0, NUMERIC_SCALE: 0,
|
||||
IsIdentity:1
|
||||
IsIdentity: 1
|
||||
})
|
||||
return response;
|
||||
}
|
||||
@ -97,7 +97,7 @@ describe('MssqlDriver', function () {
|
||||
default: 'a',
|
||||
is_nullable: true,
|
||||
isPrimary: false,
|
||||
is_generated:true,
|
||||
is_generated: true,
|
||||
name: 'name',
|
||||
numericPrecision: null,
|
||||
numericScale: null,
|
||||
@ -105,10 +105,10 @@ describe('MssqlDriver', function () {
|
||||
ts_type: 'number',
|
||||
relations: <RelationInfo[]>[]
|
||||
})
|
||||
let result = await driver.GetCoulmnsFromEntity(entities,'schema');
|
||||
let result = await driver.GetCoulmnsFromEntity(entities, 'schema');
|
||||
expect(result).to.be.deep.equal(expected)
|
||||
})
|
||||
it('should find primary indexes')
|
||||
it('should get indexes info')
|
||||
it('should get relations info')
|
||||
})
|
||||
})
|
||||
|
@ -91,4 +91,4 @@ export class Post {
|
||||
// @Column("simple-array")
|
||||
// simpleArray: string[];
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -118,4 +118,4 @@ export class Post {
|
||||
// @Column("simple-array")
|
||||
// simpleArray: string[];
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -90,4 +90,4 @@ export class Post {
|
||||
// @Column("simple-array")
|
||||
// simpleArray: string[];
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -237,4 +237,4 @@ export class Post {
|
||||
// @Column("simple-array")
|
||||
// simpleArray: string[];
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {Column, Entity,PrimaryGeneratedColumn,Index,Generated} from "typeorm";
|
||||
import { Column, Entity, PrimaryGeneratedColumn, Index, Generated } from "typeorm";
|
||||
|
||||
@Entity("Post")
|
||||
export class Post {
|
||||
@ -17,4 +17,4 @@ export class Post {
|
||||
})
|
||||
likesCount: number;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ import { PrimaryGeneratedColumn, Column, Entity, OneToOne, JoinColumn, Index } f
|
||||
|
||||
@Entity("EverythingEntity")
|
||||
export class EverythingEntity {
|
||||
//TODO: change to check column types per database engine
|
||||
//TODO: change to check column types per database engine
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number;
|
||||
|
||||
@ -69,4 +69,4 @@ export class EverythingEntity {
|
||||
// @UpdateDateColumn()
|
||||
// updatedDate: Date;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { Column, Entity, Index, PrimaryGeneratedColumn } from "typeorm"
|
||||
import { Column, Entity, Index, PrimaryGeneratedColumn } from "typeorm"
|
||||
|
||||
@Entity("Post")
|
||||
@Index("my_index_with_id_and_text", ["id", "text"], {unique:true})
|
||||
@Index("my_index_with_id_and_title", (post: Post) => [post.id, post.title], {unique:true})
|
||||
@Index("my_index_with_id_and_text", ["id", "text"], { unique: true })
|
||||
@Index("my_index_with_id_and_title", (post: Post) => [post.id, post.title], { unique: true })
|
||||
export class Post {
|
||||
|
||||
@PrimaryGeneratedColumn()
|
||||
@ -23,4 +23,4 @@ export class Post {
|
||||
@Index()
|
||||
likesCount: number;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Column, Entity, Index, PrimaryGeneratedColumn, VersionColumn } from "typeorm"
|
||||
import { Column, Entity, Index, PrimaryGeneratedColumn, VersionColumn } from "typeorm"
|
||||
|
||||
@Entity("Post")
|
||||
export class Post {
|
||||
@ -14,5 +14,5 @@ export class Post {
|
||||
|
||||
@VersionColumn()
|
||||
version: number;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ export class Post {
|
||||
@Index({ unique: true })
|
||||
category: PostCategory;
|
||||
|
||||
// post has relation with details. cascade inserts here means if new PostDetails instance will be set to this
|
||||
// post has relation with details. cascade inserts here means if new PostDetails instance will be set to this
|
||||
// relation it will be inserted automatically to the db when you save this Post entity
|
||||
@OneToOne(type => PostDetails, details => details.post, {
|
||||
cascade: true
|
||||
@ -69,4 +69,4 @@ export class Post {
|
||||
@Index({ unique: true })
|
||||
author: PostAuthor;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import {PrimaryGeneratedColumn, Column, Entity, OneToOne,JoinColumn} from "typeorm";
|
||||
import {Post} from "./Post";
|
||||
import { PrimaryGeneratedColumn, Column, Entity, OneToOne, JoinColumn } from "typeorm";
|
||||
import { Post } from "./Post";
|
||||
|
||||
@Entity("PostAuthor")
|
||||
export class PostAuthor {
|
||||
@ -13,4 +13,4 @@ export class PostAuthor {
|
||||
@OneToOne(type => Post, post => post.author)
|
||||
post: Post;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {PrimaryGeneratedColumn, Column, Entity, OneToOne,JoinColumn} from "typeorm";
|
||||
import { PrimaryGeneratedColumn, Column, Entity, OneToOne, JoinColumn } from "typeorm";
|
||||
|
||||
@Entity("PostCategory")
|
||||
export class PostCategory {
|
||||
@ -9,4 +9,4 @@ export class PostCategory {
|
||||
@Column()
|
||||
name: string;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -22,4 +22,4 @@ export class PostDetails {
|
||||
})
|
||||
post: Post;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import {PrimaryGeneratedColumn, Column, Entity, OneToOne,JoinColumn} from "typeorm";
|
||||
import {Post} from "./Post";
|
||||
import { PrimaryGeneratedColumn, Column, Entity, OneToOne, JoinColumn } from "typeorm";
|
||||
import { Post } from "./Post";
|
||||
|
||||
@Entity("PostImage")
|
||||
export class PostImage {
|
||||
@ -13,4 +13,4 @@ export class PostImage {
|
||||
@OneToOne(type => Post, post => post.image)
|
||||
post: Post;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -13,4 +13,4 @@ export class PostInformation {
|
||||
@OneToOne(type => Post, post => post.information)
|
||||
post: Post;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import {PrimaryGeneratedColumn, Column, Entity, OneToOne,JoinColumn} from "typeorm";
|
||||
import {Post} from "./Post";
|
||||
import { PrimaryGeneratedColumn, Column, Entity, OneToOne, JoinColumn } from "typeorm";
|
||||
import { Post } from "./Post";
|
||||
|
||||
@Entity("PostMetadata")
|
||||
export class PostMetadata {
|
||||
@ -13,4 +13,4 @@ export class PostMetadata {
|
||||
@OneToOne(type => Post, post => post.metadata)
|
||||
post: Post;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {Column, Entity, PrimaryColumn} from "typeorm";
|
||||
import { Column, Entity, PrimaryColumn } from "typeorm";
|
||||
|
||||
@Entity("Post")
|
||||
export class Post {
|
||||
@ -12,4 +12,4 @@ export class Post {
|
||||
@Column()
|
||||
text: string;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ export class Post {
|
||||
})
|
||||
category: PostCategory;
|
||||
|
||||
// post has relation with details. cascade inserts here means if new PostDetails instance will be set to this
|
||||
// post has relation with details. cascade inserts here means if new PostDetails instance will be set to this
|
||||
// relation it will be inserted automatically to the db when you save this Post entity
|
||||
@ManyToOne(type => PostDetails, details => details.posts, {
|
||||
cascade: true,
|
||||
@ -57,4 +57,4 @@ export class Post {
|
||||
@ManyToOne(type => PostAuthor, author => author.posts)
|
||||
author: PostAuthor;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { PrimaryGeneratedColumn, Column, Entity, OneToOne, OneToMany, ManyToOne, JoinColumn } from "typeorm";
|
||||
import {Post} from "./Post";
|
||||
import { Post } from "./Post";
|
||||
|
||||
@Entity("PostAuthor")
|
||||
export class PostAuthor {
|
||||
@ -13,4 +13,4 @@ export class PostAuthor {
|
||||
@OneToMany(type => Post, post => post.author)
|
||||
posts: Post[];
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -9,4 +9,4 @@ export class PostCategory {
|
||||
@Column()
|
||||
name: string;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -25,4 +25,4 @@ export class PostDetails {
|
||||
@OneToMany(type => Post, post => post.details)
|
||||
posts: Post[];
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -13,4 +13,4 @@ export class PostImage {
|
||||
@OneToMany(type => Post, post => post.image)
|
||||
posts: Post[];
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -13,4 +13,4 @@ export class PostInformation {
|
||||
@OneToMany(type => Post, post => post.information)
|
||||
posts: Post[];
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { PrimaryGeneratedColumn, Column, Entity, OneToOne, OneToMany, ManyToOne, JoinColumn } from "typeorm";
|
||||
import {Post} from "./Post";
|
||||
import { Post } from "./Post";
|
||||
|
||||
@Entity("PostMetadata")
|
||||
export class PostMetadata {
|
||||
@ -13,4 +13,4 @@ export class PostMetadata {
|
||||
@OneToMany(type => Post, post => post.metadata)
|
||||
posts: Post[];
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -13,4 +13,4 @@ export class Post {
|
||||
@ManyToOne(type => PostAuthor, author => author.posts2)
|
||||
author2: PostAuthor;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -13,4 +13,4 @@ export class PostAuthor {
|
||||
@OneToMany(type => Post, post => post.author2)
|
||||
posts2: Post[];
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -53,10 +53,10 @@ describe("TypeOrm examples", async function () {
|
||||
case 'mysql':
|
||||
engine = await GTU.createMysqlModels(filesOrgPathJS, resultsPath)
|
||||
break;
|
||||
case 'mariadb':
|
||||
case 'mariadb':
|
||||
engine = await GTU.createMariaDBModels(filesOrgPathJS, resultsPath)
|
||||
break;
|
||||
case 'oracle':
|
||||
case 'oracle':
|
||||
engine = await GTU.createOracleDBModels(filesOrgPathJS, resultsPath)
|
||||
break;
|
||||
|
||||
|
@ -21,7 +21,7 @@ export class EntityFileToJson {
|
||||
// if (!x.endsWith('[]')) {
|
||||
// x = x + '[]'// can't distinguish OneTwoMany from OneToOne without indexes
|
||||
// }
|
||||
x=x.trim();
|
||||
x = x.trim();
|
||||
return x;
|
||||
});
|
||||
} else {
|
||||
@ -93,7 +93,7 @@ export class EntityFileToJson {
|
||||
for (let line of lines) {
|
||||
let trimmedLine = line.trim();
|
||||
if (trimmedLine.startsWith('//')) {
|
||||
continue; //commented line
|
||||
continue; //commented line
|
||||
}
|
||||
if (isMultilineStatement)
|
||||
trimmedLine = priorPartOfMultilineStatement + ' ' + trimmedLine
|
||||
@ -102,7 +102,7 @@ export class EntityFileToJson {
|
||||
|
||||
else if (!isInClassBody) {
|
||||
if (trimmedLine.startsWith('import')) {
|
||||
continue; //import statement is not part of entity definition
|
||||
continue; //import statement is not part of entity definition
|
||||
} else if (trimmedLine.startsWith('@Entity')) {
|
||||
continue; //TODO:entity options
|
||||
} else if (trimmedLine.startsWith('export class')) {
|
||||
@ -244,7 +244,7 @@ export class EntityFileToJson {
|
||||
// if (!x.endsWith('[]')) {
|
||||
// x = x + '[]'// can't distinguish OneTwoMany from OneToOne without indexes
|
||||
// }
|
||||
x=x.trim();
|
||||
x = x.trim();
|
||||
return x;
|
||||
});
|
||||
|
||||
@ -274,15 +274,15 @@ export class EntityFileToJson {
|
||||
console.log(`${trimmedLine}`)
|
||||
}
|
||||
|
||||
retVal.columns=retVal.columns.map(col=>{
|
||||
retVal.columns = retVal.columns.map(col => {
|
||||
if (col.columnName.endsWith('Id'))
|
||||
col.columnName=col.columnName.substr(0,col.columnName.length-2)
|
||||
col.columnName = col.columnName.substr(0, col.columnName.length - 2)
|
||||
return col;
|
||||
})
|
||||
retVal.indicies=retVal.indicies.map(ind=>{
|
||||
ind.columnNames=ind.columnNames.map(colName=>{
|
||||
retVal.indicies = retVal.indicies.map(ind => {
|
||||
ind.columnNames = ind.columnNames.map(colName => {
|
||||
if (colName.endsWith('Id'))
|
||||
colName=colName.substr(0,colName.length-2)
|
||||
colName = colName.substr(0, colName.length - 2)
|
||||
return colName;
|
||||
})
|
||||
return ind;
|
||||
@ -314,4 +314,4 @@ class EntityIndex {
|
||||
indexName: string
|
||||
columnNames: string[] = []
|
||||
isUnique: boolean = false
|
||||
}
|
||||
}
|
||||
|
@ -250,4 +250,4 @@ export function compileTsFiles(fileNames: string[], options: ts.CompilerOptions)
|
||||
});
|
||||
|
||||
return compileErrors;
|
||||
}
|
||||
}
|
||||
|
@ -14,8 +14,9 @@
|
||||
"moduleResolution": "node",
|
||||
"outDir": "dist",
|
||||
"newLine": "LF"
|
||||
}, "include": [
|
||||
},
|
||||
"include": [
|
||||
"src",
|
||||
"test"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
16
typings.json
16
typings.json
@ -1,10 +1,10 @@
|
||||
{
|
||||
"globalDevDependencies": {
|
||||
"mustache": "registry:dt/mustache#0.8.2+20160510002910"
|
||||
},
|
||||
"dependencies": {
|
||||
"mssql": "registry:dt/mssql#3.3.0+20170311011547",
|
||||
"yargs": "registry:npm/yargs#5.0.0+20160907000723",
|
||||
"yn": "registry:npm/yn#1.3.0+20170508185912"
|
||||
}
|
||||
"globalDevDependencies": {
|
||||
"mustache": "registry:dt/mustache#0.8.2+20160510002910"
|
||||
},
|
||||
"dependencies": {
|
||||
"mssql": "registry:dt/mssql#3.3.0+20170311011547",
|
||||
"yargs": "registry:npm/yargs#5.0.0+20160907000723",
|
||||
"yn": "registry:npm/yn#1.3.0+20170508185912"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user