Skip to content

Commit

Permalink
sequelize typings updated; bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin Buschmann authored and Robin Buschmann committed Dec 18, 2016
1 parent b4bf97f commit 67a0e2b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
10 changes: 5 additions & 5 deletions annotations/Table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ import {DefineOptions} from "sequelize";
export function Table(options: DefineOptions<any>);
export function Table(target: any);
export function Table(any: any) {

if(typeof any === 'function') {
let target = any;

SequelizeModelService.setModelName(target, target.name);
SequelizeModelService.setTableName(target, target.name);

} else {

let options = any;

return function (target: any) {

SequelizeModelService.extendOptions(target, options);
SequelizeModelService.setModelName(target, target.name);
SequelizeModelService.setTableName(target, target.name);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"dependencies": {
"@types/node": "6.0.41",
"@types/reflect-metadata": "0.0.4",
"@types/sequelize": "4.0.36",
"@types/sequelize": "4.0.39",
"sequelize": "git+https://github.com/RobinBuschmann/sequelize.git#mysql-jsonb"
},
"devDependencies": {
Expand Down
3 changes: 2 additions & 1 deletion services/SequelizeModelService.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion services/SequelizeModelService.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions services/SequelizeModelService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class SequelizeModelService {

const options = this.getOptions(_class);

options.tableName = tableName;
if(!options.tableName) options.tableName = tableName;
}

/**
Expand Down Expand Up @@ -146,12 +146,12 @@ export class SequelizeModelService {
* Extends currently set options with specified additional options
*/
static extendOptions(_class: any, additionalOptions: DefineOptions<any>) {

const options = this.getOptions(_class);

for(let key in additionalOptions) {
if(additionalOptions.hasOwnProperty(key)) {

options[key] = additionalOptions[key];
}
}
Expand Down

0 comments on commit 67a0e2b

Please sign in to comment.