|
| 1 | +// tslint:disable:max-line-length |
1 | 2 | import { |
2 | 3 | Collection, CollectionInsertOneOptions, CollectionOptions, Cursor, Db, DeleteWriteOpResultObject, |
3 | 4 | InsertOneWriteOpResult, ObjectID, ReplaceOneOptions, UpdateWriteOpResult |
@@ -44,17 +45,15 @@ import {IDbGetParams, IFromDbOptions} from './'; |
44 | 45 | * |
45 | 46 | * Just remember to stick to the interface in case SakuraAPI is calling the method being overriden internally. |
46 | 47 | */ |
47 | | -export function SapiModelMixin<T extends Constructor<{}>>(Base?: T) { |
48 | | - Base = Base || class { |
| 48 | + |
| 49 | +export function SapiModelMixin<C extends Constructor<{}>>(base?: C) { |
| 50 | + base = base || class { |
49 | 51 | } as any; |
50 | 52 |
|
51 | | - return class extends Base { |
52 | | - constructor(...args: any[]) { |
53 | | - super(...args); |
54 | | - } |
| 53 | + return class extends base { |
55 | 54 |
|
56 | 55 | static fromDb: <T>(this: { new(): T }, json: any, options?: IFromDbOptions) => T; |
57 | | - static fromJson: <T>(this: { new(...any): T }, json: object) => T; |
| 56 | + static fromJson: <T>(this: { new(...params): T }, json: object) => T; |
58 | 57 | static fromJsonToDb: (json: any) => any; |
59 | 58 |
|
60 | 59 | static fromDbArray: <T>(this: { new(): T }, jsons: object[], options?: IFromDbOptions) => T[]; |
@@ -90,5 +89,12 @@ export function SapiModelMixin<T extends Constructor<{}>>(Base?: T) { |
90 | 89 | toDb: (changeSet?: object) => any; |
91 | 90 | toJson: (projection?: any) => any; |
92 | 91 | toJsonString: (replacer?: () => any | Array<string | number>, space?: string | number) => string; |
| 92 | + |
| 93 | + constructor(...args: any[]) { |
| 94 | + super(...args); |
| 95 | + } |
| 96 | + |
93 | 97 | }; |
94 | 98 | } |
| 99 | + |
| 100 | +// tslint:enable:max-line-length |
0 commit comments