mythix-orm 1.6.1 → 1.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/model.d.ts CHANGED
@@ -146,16 +146,18 @@ export declare class Model {
146
146
  public static getWhereWithConnection(options?: { connection: ConnectionBase }): QueryEngine;
147
147
  public getWhereWithConnection(options?: { connection: ConnectionBase }): QueryEngine;
148
148
 
149
- public static create(models: Array<Model | GenericObject>, options?: GenericObject): Promise<Array<Model>>;
150
- public static create(models: Model | GenericObject, options?: GenericObject): Promise<Model>;
149
+ public static create<T extends Model = Model>(models: Array<T>, options?: GenericObject): Promise<Array<T>>;
150
+ public static create<T extends Model = Model>(models: T, options?: GenericObject): Promise<T>;
151
+ public static create<T extends Model = Model>(models: Array<GenericObject>, options?: GenericObject): Promise<Array<T>>;
152
+ public static create<T extends Model = Model>(models: GenericObject, options?: GenericObject): Promise<T>;
151
153
  public static count(options?: GenericObject): Promise<number>;
152
- public static all(options?: GenericObject): Promise<Array<Model>>;
153
- public static fetchAll(options?: GenericObject): AsyncGenerator<Model>;
154
- public static first(limit?: number, options?: GenericObject): Promise<Model | undefined>;
155
- public static last(limit?: number, options?: GenericObject): Promise<Model | undefined>;
154
+ public static all<T extends Model = Model>(options?: GenericObject): Promise<Array<T>>;
155
+ public static fetchAll<T extends Model = Model>(options?: GenericObject): AsyncGenerator<T>;
156
+ public static first<T extends Model = Model>(limit?: number, options?: GenericObject): Promise<T | undefined>;
157
+ public static last<T extends Model = Model>(limit?: number, options?: GenericObject): Promise<T | undefined>;
156
158
  public static pluck(fields: string | Array<string>, options?: GenericObject): Promise<Array<any>>;
157
159
 
158
- public constructor(data: GenericObject, _options?: ModelOptions);
160
+ public constructor(data?: GenericObject, _options?: ModelOptions);
159
161
  public getOptions(): ModelOptions;
160
162
  public _constructor(data?: GenericObject): void;
161
163
  public _constructFields(): void;
@@ -183,7 +185,7 @@ export declare class Model {
183
185
  public onAfterCreate(context: HookContext): Promise<any>;
184
186
  public onAfterUpdate(context: HookContext): Promise<any>;
185
187
  public onAfterSave(context: HookContext): Promise<any>;
186
- public save(options?: GenericObject): Promise<Model | boolean>;
188
+ public save(options?: GenericObject): Promise<this | boolean>;
187
189
  public reload(options?: GenericObject): Promise<void>;
188
190
  public destroy(options?: GenericObject): Promise<number>;
189
191
  public toString(): string;
@@ -53,11 +53,11 @@ export declare class QueryEngine<T = ConnectionBase> {
53
53
  public unscoped(context?: GenericObject): QueryEngine;
54
54
  public toString(options?: GenericObject): string;
55
55
  public MERGE(queryEngine: QueryEngine): QueryEngine;
56
- public all(options?: GenericObject): Promise<Array<Model>>;
57
- public fetchAll(options?: GenericObject): AsyncGenerator<Model>;
58
- public first(limit?: number | null | undefined, options?: GenericObject): Promise<Model | undefined>;
59
- public last(limit?: number | null | undefined, options?: GenericObject): Promise<Model | undefined>;
60
- public update(attributes: Model | GenericObject, options?: GenericObject): Promise<number>;
56
+ public all<T extends Model = Model>(options?: GenericObject): Promise<Array<T>>;
57
+ public fetchAll<T extends Model = Model>(options?: GenericObject): AsyncGenerator<T>;
58
+ public first<T extends Model = Model>(limit?: number | null | undefined, options?: GenericObject): Promise<T | undefined>;
59
+ public last<T extends Model = Model>(limit?: number | null | undefined, options?: GenericObject): Promise<T | undefined>;
60
+ public update<T extends Model = Model>(attributes: T | GenericObject, options?: GenericObject): Promise<number>;
61
61
  public destroy(options?: GenericObject): Promise<number>;
62
62
  public average(field: Field | string, options?: GenericObject): Promise<number>;
63
63
  public count(field: Field | string, options?: GenericObject): Promise<number>;
@@ -78,51 +78,71 @@ export declare class QueryEngine<T = ConnectionBase> {
78
78
 
79
79
  declare public NOT: {
80
80
  (): QueryEngine;
81
+
82
+ name: QueryEngine;
81
83
  [ key: string ]: QueryEngine;
82
84
  };
83
85
 
84
86
  declare public AND: {
85
87
  (query: QueryEngine): QueryEngine;
88
+
89
+ name: QueryEngine;
86
90
  [ key: string ]: QueryEngine;
87
91
  };
88
92
 
89
93
  declare public OR: {
90
94
  (query: QueryEngine): QueryEngine;
95
+
96
+ name: QueryEngine;
91
97
  [ key: string ]: QueryEngine;
92
98
  };
93
99
 
94
100
  declare public DISTINCT: {
95
101
  (fullyQualifiedName: string | Field): QueryEngine;
102
+
103
+ name: QueryEngine;
96
104
  [ key: string ]: QueryEngine;
97
105
  };
98
106
 
99
107
  declare public INNER_JOIN: {
100
108
  (): QueryEngine;
109
+
110
+ name: QueryEngine;
101
111
  [ key: string ]: QueryEngine;
102
112
  };
103
113
 
104
114
  declare public LEFT_JOIN: {
105
115
  (): QueryEngine;
116
+
117
+ name: QueryEngine;
106
118
  [ key: string ]: QueryEngine;
107
119
  };
108
120
 
109
121
  declare public RIGHT_JOIN: {
110
122
  (): QueryEngine;
123
+
124
+ name: QueryEngine;
111
125
  [ key: string ]: QueryEngine;
112
126
  };
113
127
 
114
128
  declare public FULL_JOIN: {
115
129
  (): QueryEngine;
130
+
131
+ name: QueryEngine;
116
132
  [ key: string ]: QueryEngine;
117
133
  };
118
134
 
119
135
  declare public CROSS_JOIN: {
120
136
  (): QueryEngine;
137
+
138
+ name: QueryEngine;
121
139
  [ key: string ]: QueryEngine;
122
140
  };
123
141
 
124
142
  declare public JOIN: {
125
143
  (type: string | LiteralBase): QueryEngine;
144
+
145
+ name: QueryEngine;
126
146
  [ key: string ]: QueryEngine;
127
147
  };
128
148
 
@@ -137,6 +157,7 @@ export declare class QueryEngine<T = ConnectionBase> {
137
157
  public LIKE(value: string, options?: { caseSensitive: boolean }): QueryEngine;
138
158
  public NOT_LIKE(value: string, options?: { caseSensitive: boolean }): QueryEngine;
139
159
 
160
+ name: QueryEngine;
140
161
  [ key: string ]: any;
141
162
  }
142
163
 
@@ -64,7 +64,7 @@ export declare function createAndSaveAllRelatedModels(
64
64
  options?: GenericObject,
65
65
  ): Promise<Array<Model> | undefined>;
66
66
 
67
- export declare function setRelationalValues<T = Model>(
67
+ export declare function setRelationalValues<T extends Model = Model>(
68
68
  connection: ConnectionBase,
69
69
  TargetModel: ModelClass,
70
70
  targetModelInstance: T,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mythix-orm",
3
- "version": "1.6.1",
3
+ "version": "1.6.3",
4
4
  "description": "ORM for Mythix framework",
5
5
  "main": "lib/index",
6
6
  "type": "commonjs",
@@ -34,21 +34,21 @@
34
34
  "homepage": "https://github.com/th317erd/mythix-orm#readme",
35
35
  "devDependencies": {
36
36
  "@spothero/eslint-plugin-spothero": "github:spothero/eslint-plugin-spothero",
37
- "@types/node": "^18.7.16",
37
+ "@types/node": "^18.7.17",
38
38
  "better-sqlite3": "^7.6.2",
39
39
  "colors": "^1.4.0",
40
40
  "diff": "^5.1.0",
41
- "eslint": "^8.13.0",
42
- "jasmine": "^4.1.0",
41
+ "eslint": "^8.23.1",
42
+ "jasmine": "^4.4.0",
43
43
  "nyc": "^15.1.0"
44
44
  },
45
45
  "dependencies": {
46
46
  "events": "^3.3.0",
47
47
  "inflection": "^1.13.2",
48
- "moment": "^2.29.3",
49
- "nife": "^1.11.3",
48
+ "moment": "^2.29.4",
49
+ "nife": "^1.12.1",
50
50
  "sqlstring": "^2.3.3",
51
- "uuid": "^8.3.2",
51
+ "uuid": "^9.0.0",
52
52
  "xid-js": "^1.0.1"
53
53
  },
54
54
  "nyc": {