Skip to content

Commit

Permalink
Removing some extra code
Browse files Browse the repository at this point in the history
  • Loading branch information
waterfoul committed Aug 11, 2016
1 parent ebba643 commit 32c9ffb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 24 deletions.
18 changes: 1 addition & 17 deletions node/DataConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,7 @@ import * as _ from 'lodash';
import { IDataConnection } from '../shared/DataObject';
import { DataContract, IDataContractConstruct } from './DataContract';

export abstract class DataConnection<T extends DataContract> implements IDataConnection<T> {

private _dummyContract: T = null;
private get dummyContract(): T {
if (!this._dummyContract) {
this._dummyContract = new (this.getContract())(null);
}
return this._dummyContract;
}

private _fields: string[] = [];
private get fields(): string[] {
if (!this._fields.length) {
this._fields = Reflect.getMetadata('ORM:fields', this.dummyContract);
}
return this._fields;
}
export abstract class DataConnection<T extends DataContract> implements IDataConnection<T> {g

private get model(): Promise<sequelize.Model<any, any>> {
return this.getContract().getSequelizeModel();
Expand Down
10 changes: 3 additions & 7 deletions shared/DataObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,9 @@ export const registeredClasses: registeredClassMap =
export function register(moduleId: string, apiHidden: boolean = false) {
return (target: new (...args: any[]) => IDataConnection<IDataContract> | IDataContract): any => {
const idx = moduleId + '.' + (<any> target).name;
if ((<any> target).contract === true) {
Reflect.defineMetadata('ORM:dbId', idx, target);
} else {
registeredClasses[idx] = target;
Reflect.defineMetadata('ORM:registeredIndex', idx, target);
Reflect.defineMetadata('ORM:apiHidden', apiHidden, target);
}
registeredClasses[idx] = target;
Reflect.defineMetadata('ORM:registeredIndex', idx, target);
Reflect.defineMetadata('ORM:apiHidden', apiHidden, target);
};
}

Expand Down

0 comments on commit 32c9ffb

Please sign in to comment.