tspace-mysql 1.9.3 → 1.9.4
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/README.md +134 -17
- package/dist/lib/constants/index.d.ts +1 -1
- package/dist/lib/constants/index.js +8 -1
- package/dist/lib/constants/index.js.map +1 -1
- package/dist/lib/core/Abstracts/AbstractBuilder.d.ts +1 -1
- package/dist/lib/core/Abstracts/AbstractBuilder.js +1 -0
- package/dist/lib/core/Abstracts/AbstractBuilder.js.map +1 -1
- package/dist/lib/core/Blueprint.d.ts +43 -10
- package/dist/lib/core/Blueprint.js +43 -2
- package/dist/lib/core/Blueprint.js.map +1 -1
- package/dist/lib/core/Builder.d.ts +6 -6
- package/dist/lib/core/Builder.js +25 -28
- package/dist/lib/core/Builder.js.map +1 -1
- package/dist/lib/core/Contracts/Audit.d.ts +2 -2
- package/dist/lib/core/Contracts/Logger.d.ts +2 -2
- package/dist/lib/core/DB.d.ts +137 -6
- package/dist/lib/core/DB.js +153 -30
- package/dist/lib/core/DB.js.map +1 -1
- package/dist/lib/core/Driver/index.d.ts +1 -0
- package/dist/lib/core/Driver/index.js +11 -0
- package/dist/lib/core/Driver/index.js.map +1 -1
- package/dist/lib/core/Driver/mariadb/MariadbDriver.d.ts +3 -0
- package/dist/lib/core/Driver/mariadb/MariadbDriver.js +17 -2
- package/dist/lib/core/Driver/mariadb/MariadbDriver.js.map +1 -1
- package/dist/lib/core/Driver/mongodb/MongodbDriver.d.ts +3 -0
- package/dist/lib/core/Driver/mongodb/MongodbDriver.js +4 -1
- package/dist/lib/core/Driver/mongodb/MongodbDriver.js.map +1 -1
- package/dist/lib/core/Driver/mysql/MysqlDriver.d.ts +3 -0
- package/dist/lib/core/Driver/mysql/MysqlDriver.js +32 -2
- package/dist/lib/core/Driver/mysql/MysqlDriver.js.map +1 -1
- package/dist/lib/core/Driver/postgres/PostgresDriver.d.ts +3 -0
- package/dist/lib/core/Driver/postgres/PostgresDriver.js +21 -4
- package/dist/lib/core/Driver/postgres/PostgresDriver.js.map +1 -1
- package/dist/lib/core/Driver/sqlite/SqliteDriver.d.ts +3 -0
- package/dist/lib/core/Driver/sqlite/SqliteDriver.js +10 -1
- package/dist/lib/core/Driver/sqlite/SqliteDriver.js.map +1 -1
- package/dist/lib/core/Model.d.ts +331 -29
- package/dist/lib/core/Model.js +329 -19
- package/dist/lib/core/Model.js.map +1 -1
- package/dist/lib/core/Pool.js +6 -0
- package/dist/lib/core/Pool.js.map +1 -1
- package/dist/lib/core/{Queue.d.ts → Queue/index.d.ts} +115 -111
- package/dist/lib/core/Queue/index.js +283 -0
- package/dist/lib/core/Queue/index.js.map +1 -0
- package/dist/lib/core/Queue/types.d.ts +40 -0
- package/dist/lib/core/Queue/types.js +3 -0
- package/dist/lib/core/Queue/types.js.map +1 -0
- package/dist/lib/core/Queue/worker.d.ts +103 -0
- package/dist/lib/core/{Queue.js → Queue/worker.js} +251 -310
- package/dist/lib/core/Queue/worker.js.map +1 -0
- package/dist/lib/core/Repository.d.ts +40 -20
- package/dist/lib/core/Repository.js +35 -14
- package/dist/lib/core/Repository.js.map +1 -1
- package/dist/lib/core/UtilityTypes.d.ts +7 -3
- package/dist/lib/core/UtilityTypes.js.map +1 -1
- package/dist/lib/types/decorator/index.d.ts +3 -0
- package/dist/lib/types/index.d.ts +17 -16
- package/dist/lib/types/repository/index.d.ts +3 -3
- package/dist/lib/utils/index.d.ts +10 -5
- package/dist/lib/utils/index.js +42 -9
- package/dist/lib/utils/index.js.map +1 -1
- package/package.json +3 -5
- package/dist/lib/core/Queue.js.map +0 -1
package/dist/lib/core/Model.d.ts
CHANGED
|
@@ -64,6 +64,7 @@ declare class Model<TS extends Record<string, any> = any, TR = unknown, TA exten
|
|
|
64
64
|
static get table(): string | null;
|
|
65
65
|
/**
|
|
66
66
|
* The 'formatPattern' method is used to change the format of the pattern.
|
|
67
|
+
* @static
|
|
67
68
|
* @param {object} data { data , pattern }
|
|
68
69
|
* @property {Record | string} data
|
|
69
70
|
* @property {string} parttern
|
|
@@ -75,6 +76,7 @@ declare class Model<TS extends Record<string, any> = any, TR = unknown, TA exten
|
|
|
75
76
|
}): T;
|
|
76
77
|
/**
|
|
77
78
|
* The 'instance' method is used get instance.
|
|
79
|
+
* @static
|
|
78
80
|
* @override
|
|
79
81
|
* @static
|
|
80
82
|
* @returns {Model} instance of the Model
|
|
@@ -93,6 +95,7 @@ declare class Model<TS extends Record<string, any> = any, TR = unknown, TA exten
|
|
|
93
95
|
* The 'find' method is used to retrieve a single record from a database table by its primary key.
|
|
94
96
|
*
|
|
95
97
|
* It allows you to retrieve a single record from a database table that meets the specified criteria.
|
|
98
|
+
* @static
|
|
96
99
|
* @type {?object} options
|
|
97
100
|
* @property {?object} options.select
|
|
98
101
|
* @property {?object} options.except
|
|
@@ -131,6 +134,7 @@ declare class Model<TS extends Record<string, any> = any, TR = unknown, TA exten
|
|
|
131
134
|
* The 'findOne' method is used to retrieve the get record that matches the query conditions.
|
|
132
135
|
*
|
|
133
136
|
* It allows you to retrieve a single record from a database table that meets the specified criteria.
|
|
137
|
+
* @static
|
|
134
138
|
* @type {?object} options
|
|
135
139
|
* @property {?object} options.select
|
|
136
140
|
* @property {?object} options.except
|
|
@@ -169,6 +173,7 @@ declare class Model<TS extends Record<string, any> = any, TR = unknown, TA exten
|
|
|
169
173
|
* The 'findMany' method is used to retrieve the get record that matches the query conditions.
|
|
170
174
|
*
|
|
171
175
|
* It allows you to retrieve a single record from a database table that meets the specified criteria.
|
|
176
|
+
* @static
|
|
172
177
|
* @type {?object} options
|
|
173
178
|
* @property {?object} options.select
|
|
174
179
|
* @property {?object} options.except
|
|
@@ -208,6 +213,7 @@ declare class Model<TS extends Record<string, any> = any, TR = unknown, TA exten
|
|
|
208
213
|
*
|
|
209
214
|
* It allows you to split a large set of query results into smaller, more manageable pages,
|
|
210
215
|
* making it easier to display data in a web application and improve user experience.
|
|
216
|
+
* @static
|
|
211
217
|
* @type {?object} options
|
|
212
218
|
* @property {?object} options.select
|
|
213
219
|
* @property {?object} options.except
|
|
@@ -249,6 +255,7 @@ declare class Model<TS extends Record<string, any> = any, TR = unknown, TA exten
|
|
|
249
255
|
* The 'exists' method is used to determine if any records exist in the database table that match the query conditions.
|
|
250
256
|
*
|
|
251
257
|
* It returns a boolean value indicating whether there are any matching records.
|
|
258
|
+
* @static
|
|
252
259
|
* @type {?object} options
|
|
253
260
|
* @property {?object} options.select
|
|
254
261
|
* @property {?object} options.except
|
|
@@ -277,11 +284,12 @@ declare class Model<TS extends Record<string, any> = any, TR = unknown, TA exten
|
|
|
277
284
|
* })
|
|
278
285
|
*
|
|
279
286
|
*/
|
|
280
|
-
static exists<Self extends Model, M extends Model = Self>(this: new () => Self, options: Partial<Omit<T.RepositoryOptions<M>, "relations" | "relationQuery">>): Promise<boolean>;
|
|
287
|
+
static exists<Self extends Model, M extends Model = Self>(this: new () => Self, options: Partial<Omit<T.RepositoryOptions<M>, "relations" | "relationsExists" | "relationQuery">>): Promise<boolean>;
|
|
281
288
|
/**
|
|
282
289
|
* The 'toQuery' method is used to retrieve the raw SQL query that would be executed by a query builder instance without actually executing it.
|
|
283
290
|
*
|
|
284
291
|
* This method is particularly useful for debugging and understanding the SQL queries generated by your application.
|
|
292
|
+
* @static
|
|
285
293
|
* @type {?object} options
|
|
286
294
|
* @property {?object} options.select
|
|
287
295
|
* @property {?object} options.except
|
|
@@ -310,11 +318,248 @@ declare class Model<TS extends Record<string, any> = any, TR = unknown, TA exten
|
|
|
310
318
|
* })
|
|
311
319
|
*
|
|
312
320
|
*/
|
|
313
|
-
static toQuery<Self extends Model, M extends Model = Self>(this: new () => Self, options: Partial<Omit<T.RepositoryOptions<M>, "relations" | "relationQuery">>): string;
|
|
321
|
+
static toQuery<Self extends Model, M extends Model = Self>(this: new () => Self, options: Partial<Omit<T.RepositoryOptions<M>, "relations" | "relationsExists" | "relationQuery">>): string;
|
|
322
|
+
/**
|
|
323
|
+
* The 'toArray' method is used to retrieve the raw SQL query that would be executed by a query builder instance without actually executing it.
|
|
324
|
+
*
|
|
325
|
+
* This method is particularly useful for debugging and understanding the SQL queries generated by your application.
|
|
326
|
+
* @static
|
|
327
|
+
* @type {?object} options
|
|
328
|
+
* @property {?object} options.select
|
|
329
|
+
* @property {?object} options.except
|
|
330
|
+
* @property {?object[]} options.orderBy
|
|
331
|
+
* @property {?string[]} options.groupBy
|
|
332
|
+
* @property {?string} options.having
|
|
333
|
+
* @property {?number} options.limit
|
|
334
|
+
* @property {?number} options.offset
|
|
335
|
+
* @property {?object} options.where
|
|
336
|
+
* @property {?string[]} options.whereRaw
|
|
337
|
+
* @property {?object} options.whereQuery
|
|
338
|
+
* @property {?{condition,callback}} options.when
|
|
339
|
+
* @property {?{localKey , referenceKey}[]} options.join
|
|
340
|
+
* @property {?{localKey , referenceKey}[]} options.rightJoin
|
|
341
|
+
* @property {?{localKey , referenceKey}[]} options.leftJoin
|
|
342
|
+
* @property {?boolean} options.debug
|
|
343
|
+
* @property {?number} options.page
|
|
344
|
+
*
|
|
345
|
+
* @example
|
|
346
|
+
* import { User } from '../Models/User'
|
|
347
|
+
*
|
|
348
|
+
* const users = await User.toArray('id',{
|
|
349
|
+
* where : {
|
|
350
|
+
* id: 1
|
|
351
|
+
* }
|
|
352
|
+
* })
|
|
353
|
+
*
|
|
354
|
+
* // [1]
|
|
355
|
+
*
|
|
356
|
+
*/
|
|
357
|
+
static toArray<Self extends Model, K extends T.ColumnKeys<M> | `${string}.${string}`, M extends Model = Self>(this: new () => Self, column: K, options?: Partial<Omit<T.RepositoryOptions<M>, "relations" | "relationsExists" | "relationQuery">>): Promise<(K extends keyof T.Result<M> ? T.Result<M>[K] : unknown)[]>;
|
|
358
|
+
/**
|
|
359
|
+
*
|
|
360
|
+
* The 'toAsyncIterable' method is used to execute a database query and return the result set as an asynchronous iterable.
|
|
361
|
+
*
|
|
362
|
+
* It retrieves multiple records from a database table based on the criteria specified in the query.
|
|
363
|
+
* The optional callback function can be used to modify the generated SQL query before execution.
|
|
364
|
+
* @static
|
|
365
|
+
* @type {?object} options
|
|
366
|
+
* @property {?object} options.select
|
|
367
|
+
* @property {?object} options.except
|
|
368
|
+
* @property {?object[]} options.orderBy
|
|
369
|
+
* @property {?string[]} options.groupBy
|
|
370
|
+
* @property {?string} options.having
|
|
371
|
+
* @property {?number} options.limit
|
|
372
|
+
* @property {?number} options.offset
|
|
373
|
+
* @property {?object} options.where
|
|
374
|
+
* @property {?string[]} options.whereRaw
|
|
375
|
+
* @property {?object} options.whereQuery
|
|
376
|
+
* @property {?{condition,callback}} options.when
|
|
377
|
+
* @property {?{localKey , referenceKey}[]} options.join
|
|
378
|
+
* @property {?{localKey , referenceKey}[]} options.rightJoin
|
|
379
|
+
* @property {?{localKey , referenceKey}[]} options.leftJoin
|
|
380
|
+
* @property {?string[]} options.relations
|
|
381
|
+
* @property {string[]} options.relationExists
|
|
382
|
+
* @property {?{condition,callback}} options.relationQuery
|
|
383
|
+
* @property {?boolean} options.debug
|
|
384
|
+
* @returns {promise<object>[]}
|
|
385
|
+
*
|
|
386
|
+
* @example
|
|
387
|
+
* import { User } from '../Models/User'
|
|
388
|
+
*
|
|
389
|
+
* const users = await User.findMany({
|
|
390
|
+
* select : { id: true, name: true },
|
|
391
|
+
* where : {
|
|
392
|
+
* id: 1
|
|
393
|
+
* }
|
|
394
|
+
* })
|
|
395
|
+
*
|
|
396
|
+
*/
|
|
397
|
+
static toAsyncIterable<Self extends Model, M extends Model = Self, S extends T.SelectOptions<M> | undefined = undefined, SR extends T.RelationOptions<M> | undefined = undefined, E extends T.ExceptOptions<M> | undefined = undefined, SRS extends Record<string, TRawStringQuery> | undefined = undefined, G extends Record<string, T.RepositoryGenericTypeOptions> | undefined = {}>(this: new () => Self, options?: T.RepositoryOptions<M, S, SR, E, SRS, G>): AsyncIterable<T.ResultFiltered<M, S, SR, E, SRS, G>>;
|
|
398
|
+
/**
|
|
399
|
+
* The 'count' method is used to retrieve the total number of records that match the specified query conditions.
|
|
400
|
+
*
|
|
401
|
+
* It returns an integer representing the count of records.
|
|
402
|
+
* @static
|
|
403
|
+
* @type {?object} options
|
|
404
|
+
* @property {?object} options.select
|
|
405
|
+
* @property {?object} options.except
|
|
406
|
+
* @property {?object[]} options.orderBy
|
|
407
|
+
* @property {?string[]} options.groupBy
|
|
408
|
+
* @property {?string} options.having
|
|
409
|
+
* @property {?number} options.limit
|
|
410
|
+
* @property {?number} options.offset
|
|
411
|
+
* @property {?object} options.where
|
|
412
|
+
* @property {?string[]} options.whereRaw
|
|
413
|
+
* @property {?object} options.whereQuery
|
|
414
|
+
* @property {?{condition,callback}} options.when
|
|
415
|
+
* @property {?{localKey , referenceKey}[]} options.join
|
|
416
|
+
* @property {?{localKey , referenceKey}[]} options.rightJoin
|
|
417
|
+
* @property {?{localKey , referenceKey}[]} options.leftJoin
|
|
418
|
+
* @property {?boolean} options.debug
|
|
419
|
+
* @property {?number} options.page
|
|
420
|
+
*
|
|
421
|
+
* @example
|
|
422
|
+
* import { User } from '../Models/User'
|
|
423
|
+
*
|
|
424
|
+
* const count = await User.count('id',{
|
|
425
|
+
* where : {
|
|
426
|
+
* id: 1
|
|
427
|
+
* }
|
|
428
|
+
* })
|
|
429
|
+
*
|
|
430
|
+
* // 1
|
|
431
|
+
*
|
|
432
|
+
*/
|
|
433
|
+
static count<Self extends Model, K extends T.ColumnKeys<M> | `${string}.${string}`, M extends Model = Self>(this: new () => Self, column: K, options?: Partial<Omit<T.RepositoryOptions<M>, "relations" | "relationsExists" | "relationQuery">>): Promise<number>;
|
|
434
|
+
/**
|
|
435
|
+
* The 'sum' method is used to retrieve the total number of records that match the specified query conditions.
|
|
436
|
+
*
|
|
437
|
+
* It returns an integer representing the sum of records.
|
|
438
|
+
* @static
|
|
439
|
+
* @type {?object} options
|
|
440
|
+
* @property {?object} options.select
|
|
441
|
+
* @property {?object} options.except
|
|
442
|
+
* @property {?object[]} options.orderBy
|
|
443
|
+
* @property {?string[]} options.groupBy
|
|
444
|
+
* @property {?string} options.having
|
|
445
|
+
* @property {?number} options.limit
|
|
446
|
+
* @property {?number} options.offset
|
|
447
|
+
* @property {?object} options.where
|
|
448
|
+
* @property {?string[]} options.whereRaw
|
|
449
|
+
* @property {?object} options.whereQuery
|
|
450
|
+
* @property {?{condition,callback}} options.when
|
|
451
|
+
* @property {?{localKey , referenceKey}[]} options.join
|
|
452
|
+
* @property {?{localKey , referenceKey}[]} options.rightJoin
|
|
453
|
+
* @property {?{localKey , referenceKey}[]} options.leftJoin
|
|
454
|
+
* @property {?boolean} options.debug
|
|
455
|
+
* @property {?number} options.page
|
|
456
|
+
*
|
|
457
|
+
* @example
|
|
458
|
+
* import { User } from '../Models/User'
|
|
459
|
+
*
|
|
460
|
+
* const sum = await User.sum('id')
|
|
461
|
+
*
|
|
462
|
+
*
|
|
463
|
+
*/
|
|
464
|
+
static sum<Self extends Model, K extends T.ColumnKeys<M> | `${string}.${string}`, M extends Model = Self>(this: new () => Self, column: K, options?: Partial<Omit<T.RepositoryOptions<M>, "relations" | "relationsExists" | "relationQuery">>): Promise<number>;
|
|
465
|
+
/**
|
|
466
|
+
* The 'avg' method is used to retrieve the total number of records that match the specified query conditions.
|
|
467
|
+
*
|
|
468
|
+
* It returns an integer representing the avg of records.
|
|
469
|
+
* @static
|
|
470
|
+
* @type {?object} options
|
|
471
|
+
* @property {?object} options.select
|
|
472
|
+
* @property {?object} options.except
|
|
473
|
+
* @property {?object[]} options.orderBy
|
|
474
|
+
* @property {?string[]} options.groupBy
|
|
475
|
+
* @property {?string} options.having
|
|
476
|
+
* @property {?number} options.limit
|
|
477
|
+
* @property {?number} options.offset
|
|
478
|
+
* @property {?object} options.where
|
|
479
|
+
* @property {?string[]} options.whereRaw
|
|
480
|
+
* @property {?object} options.whereQuery
|
|
481
|
+
* @property {?{condition,callback}} options.when
|
|
482
|
+
* @property {?{localKey , referenceKey}[]} options.join
|
|
483
|
+
* @property {?{localKey , referenceKey}[]} options.rightJoin
|
|
484
|
+
* @property {?{localKey , referenceKey}[]} options.leftJoin
|
|
485
|
+
* @property {?boolean} options.debug
|
|
486
|
+
* @property {?number} options.page
|
|
487
|
+
*
|
|
488
|
+
* @example
|
|
489
|
+
* import { User } from '../Models/User'
|
|
490
|
+
*
|
|
491
|
+
* const avg = await User.avg('id')
|
|
492
|
+
*
|
|
493
|
+
*
|
|
494
|
+
*/
|
|
495
|
+
static avg<Self extends Model, K extends T.ColumnKeys<M> | `${string}.${string}`, M extends Model = Self>(this: new () => Self, column: K, options?: Partial<Omit<T.RepositoryOptions<M>, "relations" | "relationsExists" | "relationQuery">>): Promise<number>;
|
|
496
|
+
/**
|
|
497
|
+
* The 'max' method is used to retrieve the total number of records that match the specified query conditions.
|
|
498
|
+
*
|
|
499
|
+
* It returns an integer representing the max of records.
|
|
500
|
+
* @static
|
|
501
|
+
* @type {?object} options
|
|
502
|
+
* @property {?object} options.select
|
|
503
|
+
* @property {?object} options.except
|
|
504
|
+
* @property {?object[]} options.orderBy
|
|
505
|
+
* @property {?string[]} options.groupBy
|
|
506
|
+
* @property {?string} options.having
|
|
507
|
+
* @property {?number} options.limit
|
|
508
|
+
* @property {?number} options.offset
|
|
509
|
+
* @property {?object} options.where
|
|
510
|
+
* @property {?string[]} options.whereRaw
|
|
511
|
+
* @property {?object} options.whereQuery
|
|
512
|
+
* @property {?{condition,callback}} options.when
|
|
513
|
+
* @property {?{localKey , referenceKey}[]} options.join
|
|
514
|
+
* @property {?{localKey , referenceKey}[]} options.rightJoin
|
|
515
|
+
* @property {?{localKey , referenceKey}[]} options.leftJoin
|
|
516
|
+
* @property {?boolean} options.debug
|
|
517
|
+
* @property {?number} options.page
|
|
518
|
+
*
|
|
519
|
+
* @example
|
|
520
|
+
* import { User } from '../Models/User'
|
|
521
|
+
*
|
|
522
|
+
* const max = await User.max('id')
|
|
523
|
+
*
|
|
524
|
+
*
|
|
525
|
+
*/
|
|
526
|
+
static max<Self extends Model, K extends T.ColumnKeys<M> | `${string}.${string}`, M extends Model = Self>(this: new () => Self, column: K, options?: Partial<Omit<T.RepositoryOptions<M>, "relations" | "relationsExists" | "relationQuery">>): Promise<number>;
|
|
527
|
+
/**
|
|
528
|
+
* The 'min' method is used to retrieve the total number of records that match the specified query conditions.
|
|
529
|
+
*
|
|
530
|
+
* It returns an integer representing the min of records.
|
|
531
|
+
* @static
|
|
532
|
+
* @type {?object} options
|
|
533
|
+
* @property {?object} options.select
|
|
534
|
+
* @property {?object} options.except
|
|
535
|
+
* @property {?object[]} options.orderBy
|
|
536
|
+
* @property {?string[]} options.groupBy
|
|
537
|
+
* @property {?string} options.having
|
|
538
|
+
* @property {?number} options.limit
|
|
539
|
+
* @property {?number} options.offset
|
|
540
|
+
* @property {?object} options.where
|
|
541
|
+
* @property {?string[]} options.whereRaw
|
|
542
|
+
* @property {?object} options.whereQuery
|
|
543
|
+
* @property {?{condition,callback}} options.when
|
|
544
|
+
* @property {?{localKey , referenceKey}[]} options.join
|
|
545
|
+
* @property {?{localKey , referenceKey}[]} options.rightJoin
|
|
546
|
+
* @property {?{localKey , referenceKey}[]} options.leftJoin
|
|
547
|
+
* @property {?boolean} options.debug
|
|
548
|
+
* @property {?number} options.page
|
|
549
|
+
*
|
|
550
|
+
* @example
|
|
551
|
+
* import { User } from '../Models/User'
|
|
552
|
+
*
|
|
553
|
+
* const min = await User.min('id')
|
|
554
|
+
*
|
|
555
|
+
*
|
|
556
|
+
*/
|
|
557
|
+
static min<Self extends Model, K extends T.ColumnKeys<M> | `${string}.${string}`, M extends Model = Self>(this: new () => Self, column: K, options?: Partial<Omit<T.RepositoryOptions<M>, "relations" | "relationsExists" | "relationQuery">>): Promise<number>;
|
|
314
558
|
/**
|
|
315
559
|
* The 'create' method is used to insert a new record into a database table associated.
|
|
316
560
|
*
|
|
317
561
|
* It simplifies the process of creating and inserting records.
|
|
562
|
+
* @static
|
|
318
563
|
* @type {object} options
|
|
319
564
|
* @property {object} options.data
|
|
320
565
|
* @property {?boolean} options.debug
|
|
@@ -326,6 +571,7 @@ declare class Model<TS extends Record<string, any> = any, TR = unknown, TA exten
|
|
|
326
571
|
* The 'createMany' method is used to insert a new records into a database table associated.
|
|
327
572
|
*
|
|
328
573
|
* It simplifies the process of creating and inserting records with an array.
|
|
574
|
+
* @static
|
|
329
575
|
* @type {object} options
|
|
330
576
|
* @property {object[]} options.data
|
|
331
577
|
* @property {?boolean} options.debug
|
|
@@ -339,6 +585,7 @@ declare class Model<TS extends Record<string, any> = any, TR = unknown, TA exten
|
|
|
339
585
|
*
|
|
340
586
|
* This method is particularly useful when you want to update a record based on certain conditions and,
|
|
341
587
|
* if the record matching those conditions doesn't exist, create a new one with the provided data.
|
|
588
|
+
* @static
|
|
342
589
|
* @type {object} options
|
|
343
590
|
* @property {object} options.data
|
|
344
591
|
* @property {object} options.where
|
|
@@ -351,7 +598,7 @@ declare class Model<TS extends Record<string, any> = any, TR = unknown, TA exten
|
|
|
351
598
|
*
|
|
352
599
|
* This method is particularly useful when you want to insert records into a table and ensure that duplicates are not inserted,
|
|
353
600
|
* but without raising an error or exception if duplicates are encountered.
|
|
354
|
-
*
|
|
601
|
+
* @static
|
|
355
602
|
* @type {object} options
|
|
356
603
|
* @property {object} options.data
|
|
357
604
|
* @property {object} options.where
|
|
@@ -366,6 +613,7 @@ declare class Model<TS extends Record<string, any> = any, TR = unknown, TA exten
|
|
|
366
613
|
*
|
|
367
614
|
* This method is particularly useful when you want to insert records into a table and ensure that duplicates are not inserted,
|
|
368
615
|
* but if exists should be returns a result.
|
|
616
|
+
* @static
|
|
369
617
|
* @type {object} options
|
|
370
618
|
* @property {object} options.data
|
|
371
619
|
* @property {object} options.where
|
|
@@ -379,6 +627,7 @@ declare class Model<TS extends Record<string, any> = any, TR = unknown, TA exten
|
|
|
379
627
|
* It simplifies the process of updating records by allowing you to specify the values to be updated using a single call.
|
|
380
628
|
*
|
|
381
629
|
* It allows you to remove one record that match certain criteria.
|
|
630
|
+
* @static
|
|
382
631
|
* @type {object} options
|
|
383
632
|
* @property {object} options.data
|
|
384
633
|
* @property {object} options.where
|
|
@@ -393,6 +642,7 @@ declare class Model<TS extends Record<string, any> = any, TR = unknown, TA exten
|
|
|
393
642
|
* It simplifies the process of updating records by allowing you to specify the values to be updated using a single call.
|
|
394
643
|
*
|
|
395
644
|
* It allows you to remove more records that match certain criteria.
|
|
645
|
+
* @static
|
|
396
646
|
* @type {object} options
|
|
397
647
|
* @property {object} options.data
|
|
398
648
|
* @property {object} options.where
|
|
@@ -402,8 +652,52 @@ declare class Model<TS extends Record<string, any> = any, TR = unknown, TA exten
|
|
|
402
652
|
*/
|
|
403
653
|
static updateMany<Self extends Model, M extends Model = Self, NR extends boolean | undefined = false>(this: new () => Self, options: T.RepositoryUpdate<M, NR>): Promise<NR extends true ? undefined : T.Result<M>[]>;
|
|
404
654
|
/**
|
|
405
|
-
* The 'cache' method is used
|
|
406
|
-
*
|
|
655
|
+
* The 'cache' method is used to access to cache operations for the current model.
|
|
656
|
+
*
|
|
657
|
+
* The cache API exposes methods for retrieving the configured cache provider,
|
|
658
|
+
* selecting a cache driver, managing cache entries, and optionally generating
|
|
659
|
+
* model-scoped cache keys.
|
|
660
|
+
*
|
|
661
|
+
* When the `namespace` option is enabled, cache keys are automatically prefixed
|
|
662
|
+
* with the current database and table name in the following format:
|
|
663
|
+
*
|
|
664
|
+
* `database:table:key`
|
|
665
|
+
*
|
|
666
|
+
* This helps prevent cache key collisions between different models or tables.
|
|
667
|
+
* @static
|
|
668
|
+
* @returns {TCacheModel} An object containing cache provider, driver, and cache management methods.
|
|
669
|
+
*
|
|
670
|
+
* @example
|
|
671
|
+
* // Get the configured cache provider.
|
|
672
|
+
* const provider = User.cache.provider(); // "db" | "memory" | "redis"
|
|
673
|
+
*
|
|
674
|
+
* @example
|
|
675
|
+
* // Store a value using a model-scoped cache key.
|
|
676
|
+
* await User.cache.set("users", users, 60_000, {
|
|
677
|
+
* namespace: true
|
|
678
|
+
* });
|
|
679
|
+
*
|
|
680
|
+
* @example
|
|
681
|
+
* // Retrieve a model-scoped cache value.
|
|
682
|
+
* const users = await User.cache.get("users", {
|
|
683
|
+
* namespace: true
|
|
684
|
+
* });
|
|
685
|
+
*
|
|
686
|
+
* @example
|
|
687
|
+
* // Check whether a cache entry exists.
|
|
688
|
+
* const exists = await User.cache.exists("users", {
|
|
689
|
+
* namespace: true
|
|
690
|
+
* });
|
|
691
|
+
*
|
|
692
|
+
* @example
|
|
693
|
+
* // Delete a cache entry.
|
|
694
|
+
* await User.cache.delete("users", {
|
|
695
|
+
* namespace: true
|
|
696
|
+
* });
|
|
697
|
+
*
|
|
698
|
+
* @example
|
|
699
|
+
* // Clear all cache entries.
|
|
700
|
+
* await User.cache.clear();
|
|
407
701
|
*/
|
|
408
702
|
static get cache(): TCacheModel;
|
|
409
703
|
/**
|
|
@@ -428,6 +722,7 @@ declare class Model<TS extends Record<string, any> = any, TR = unknown, TA exten
|
|
|
428
722
|
* - DELETE: waits
|
|
429
723
|
*
|
|
430
724
|
* The lock is released automatically after the callback completes.
|
|
725
|
+
* @static
|
|
431
726
|
*
|
|
432
727
|
* @Note
|
|
433
728
|
* This approach is not recommended in clustered or load-balance environments,
|
|
@@ -1941,8 +2236,8 @@ declare class Model<TS extends Record<string, any> = any, TR = unknown, TA exten
|
|
|
1941
2236
|
* @param {Object} columns
|
|
1942
2237
|
* @returns {this}
|
|
1943
2238
|
*/
|
|
1944
|
-
whereObject<K extends T.ColumnKeys<this>,
|
|
1945
|
-
[P in K & keyof
|
|
2239
|
+
whereObject<K extends T.ColumnKeys<this>, CO extends T.ColumnOptions<this>>(columns: {
|
|
2240
|
+
[P in K & keyof CO]: CO[P];
|
|
1946
2241
|
}): this;
|
|
1947
2242
|
/**
|
|
1948
2243
|
* @override
|
|
@@ -1991,28 +2286,28 @@ declare class Model<TS extends Record<string, any> = any, TR = unknown, TA exten
|
|
|
1991
2286
|
* @param {array} array
|
|
1992
2287
|
* @returns {this}
|
|
1993
2288
|
*/
|
|
1994
|
-
whereIn<K extends T.ColumnKeys<this>>(column: K, array:
|
|
2289
|
+
whereIn<K extends T.ColumnKeys<this>, V extends T.ColumnValue<this, K>>(column: K, array: V[]): this;
|
|
1995
2290
|
/**
|
|
1996
2291
|
* @override
|
|
1997
2292
|
* @param {string} column
|
|
1998
2293
|
* @param {array} array
|
|
1999
2294
|
* @returns {this}
|
|
2000
2295
|
*/
|
|
2001
|
-
orWhereIn<K extends T.ColumnKeys<this>>(column: K, array:
|
|
2296
|
+
orWhereIn<K extends T.ColumnKeys<this>, V extends T.ColumnValue<this, K>>(column: K, array: V[]): this;
|
|
2002
2297
|
/**
|
|
2003
2298
|
* @override
|
|
2004
2299
|
* @param {string} column
|
|
2005
2300
|
* @param {array} array
|
|
2006
2301
|
* @returns {this}
|
|
2007
2302
|
*/
|
|
2008
|
-
whereNotIn<K extends T.ColumnKeys<this>>(column: K, array:
|
|
2303
|
+
whereNotIn<K extends T.ColumnKeys<this>, V extends T.ColumnValue<this, K>>(column: K, array: V[]): this;
|
|
2009
2304
|
/**
|
|
2010
2305
|
* @override
|
|
2011
2306
|
* @param {string} column
|
|
2012
2307
|
* @param {array} array
|
|
2013
2308
|
* @returns {this}
|
|
2014
2309
|
*/
|
|
2015
|
-
orWhereNotIn<K extends T.ColumnKeys<this>>(column: K, array:
|
|
2310
|
+
orWhereNotIn<K extends T.ColumnKeys<this>, V extends T.ColumnValue<this, K>>(column: K, array: V[]): this;
|
|
2016
2311
|
/**
|
|
2017
2312
|
* @override
|
|
2018
2313
|
* @param {string} column
|
|
@@ -2381,6 +2676,13 @@ declare class Model<TS extends Record<string, any> = any, TR = unknown, TA exten
|
|
|
2381
2676
|
latest?: boolean;
|
|
2382
2677
|
oldest?: boolean;
|
|
2383
2678
|
}): string;
|
|
2679
|
+
/**
|
|
2680
|
+
*
|
|
2681
|
+
* @override
|
|
2682
|
+
* @param {Function?} cb callback function return query sql
|
|
2683
|
+
* @returns {AsyncIterable<T.Result<this, K>>}
|
|
2684
|
+
*/
|
|
2685
|
+
toAsyncIterable<K>(cb?: Function): AsyncIterable<T.Result<this, K>>;
|
|
2384
2686
|
/**
|
|
2385
2687
|
* @override
|
|
2386
2688
|
* @param {string=} column [column=id]
|
|
@@ -2493,27 +2795,27 @@ declare class Model<TS extends Record<string, any> = any, TR = unknown, TA exten
|
|
|
2493
2795
|
* @param {object} data for insert
|
|
2494
2796
|
* @returns {this} this
|
|
2495
2797
|
*/
|
|
2496
|
-
insert<K extends T.ColumnKeys<this>, C extends T.
|
|
2798
|
+
insert<K extends T.ColumnKeys<this>, C extends T.InputOptions<this>>(data: T.InsertInput<K, C>): Model<TS, TR, "create">;
|
|
2497
2799
|
/**
|
|
2498
2800
|
* @override
|
|
2499
2801
|
* @param {object} data for insert
|
|
2500
2802
|
* @returns {this} this
|
|
2501
2803
|
*/
|
|
2502
|
-
create<K extends T.ColumnKeys<this>, C extends T.
|
|
2804
|
+
create<K extends T.ColumnKeys<this>, C extends T.InputOptions<this>>(data: T.InsertInput<K, C>): Model<TS, TR, "create">;
|
|
2503
2805
|
/**
|
|
2504
2806
|
* @override
|
|
2505
2807
|
* @param {object} data
|
|
2506
2808
|
* @param {array?} updateNotExists options for except update some records in your ${data}
|
|
2507
2809
|
* @returns {this} this
|
|
2508
2810
|
*/
|
|
2509
|
-
update<K extends T.ColumnKeys<this>, C extends T.
|
|
2811
|
+
update<K extends T.ColumnKeys<this>, C extends T.InputOptions<this>>(data: T.UpdateInput<K, C>, updateNotExists?: T.ColumnKeys<this>[]): Model<TS, TR, "update">;
|
|
2510
2812
|
/**
|
|
2511
2813
|
* @override
|
|
2512
2814
|
* @param {object} data
|
|
2513
2815
|
* @param {array?} updateNotExists options for except update some records in your ${data}
|
|
2514
2816
|
* @returns {this} this
|
|
2515
2817
|
*/
|
|
2516
|
-
updateMany<K extends T.ColumnKeys<this>, C extends T.
|
|
2818
|
+
updateMany<K extends T.ColumnKeys<this>, C extends T.InputOptions<this>>(data: T.UpdateInput<K, C>, updateNotExists?: string[]): Model<TS, TR, "updateMany">;
|
|
2517
2819
|
/**
|
|
2518
2820
|
*
|
|
2519
2821
|
* @override
|
|
@@ -2526,7 +2828,7 @@ declare class Model<TS extends Record<string, any> = any, TR = unknown, TA exten
|
|
|
2526
2828
|
* @property {Record<string,string | number | boolean | null | undefined>} cases.columns
|
|
2527
2829
|
* @returns {this} this
|
|
2528
2830
|
*/
|
|
2529
|
-
updateCases<T extends T.
|
|
2831
|
+
updateCases<T extends T.InputOptions<this>, K extends keyof T, U extends Model | unknown, M = U extends this ? this : U extends Model ? U : this>(cases: {
|
|
2530
2832
|
condition: ((query: M) => M) | Partial<{
|
|
2531
2833
|
[P in K & keyof T]: Extract<T[P], Record<string, unknown>> extends never ? T[P] : string;
|
|
2532
2834
|
}>;
|
|
@@ -2539,84 +2841,84 @@ declare class Model<TS extends Record<string, any> = any, TR = unknown, TA exten
|
|
|
2539
2841
|
* @param {object} data
|
|
2540
2842
|
* @returns {this} this
|
|
2541
2843
|
*/
|
|
2542
|
-
updateNotExists<K extends T.ColumnKeys<this>, C extends T.
|
|
2844
|
+
updateNotExists<K extends T.ColumnKeys<this>, C extends T.InputOptions<this>>(data: T.UpdateInput<K, C>): Model<TS, TR, "update">;
|
|
2543
2845
|
/**
|
|
2544
2846
|
* @override
|
|
2545
2847
|
* @param {object} data for update or create
|
|
2546
2848
|
* @returns {this} this
|
|
2547
2849
|
*/
|
|
2548
|
-
updateOrCreate<K extends T.ColumnKeys<this>, C extends T.
|
|
2850
|
+
updateOrCreate<K extends T.ColumnKeys<this>, C extends T.InputOptions<this>>(data: T.InsertOrUpdateInput<K, C>): Model<TS, TR, "createOrUpdate">;
|
|
2549
2851
|
/**
|
|
2550
2852
|
* @override
|
|
2551
2853
|
* @param {object} data for update or create
|
|
2552
2854
|
* @returns {this} this
|
|
2553
2855
|
*/
|
|
2554
|
-
updateOrInsert<K extends T.ColumnKeys<this>, C extends T.
|
|
2856
|
+
updateOrInsert<K extends T.ColumnKeys<this>, C extends T.InputOptions<this>>(data: T.InsertOrUpdateInput<K, C>): Model<TS, TR, "createOrUpdate">;
|
|
2555
2857
|
/**
|
|
2556
2858
|
* @override
|
|
2557
2859
|
* @param {object} data for update or create
|
|
2558
2860
|
* @returns {this} this
|
|
2559
2861
|
*/
|
|
2560
|
-
insertOrUpdate<K extends T.ColumnKeys<this>, C extends T.
|
|
2862
|
+
insertOrUpdate<K extends T.ColumnKeys<this>, C extends T.InputOptions<this>>(data: T.InsertOrUpdateInput<K, C>): Model<TS, TR, "createOrUpdate">;
|
|
2561
2863
|
/**
|
|
2562
2864
|
* @override
|
|
2563
2865
|
* @param {object} data for update or create
|
|
2564
2866
|
* @returns {this} this
|
|
2565
2867
|
*/
|
|
2566
|
-
createOrUpdate<K extends T.ColumnKeys<this>, C extends T.
|
|
2868
|
+
createOrUpdate<K extends T.ColumnKeys<this>, C extends T.InputOptions<this>>(data: T.InsertOrUpdateInput<K, C>): Model<TS, TR, "createOrUpdate">;
|
|
2567
2869
|
/**
|
|
2568
2870
|
* @override
|
|
2569
2871
|
* @param {object} data for create
|
|
2570
2872
|
* @returns {this} this
|
|
2571
2873
|
*/
|
|
2572
|
-
createOrSelect<K extends T.ColumnKeys<this>, C extends T.
|
|
2874
|
+
createOrSelect<K extends T.ColumnKeys<this>, C extends T.InputOptions<this>>(data: T.InsertInput<K, C>): Model<TS, TR, "createOrSelect">;
|
|
2573
2875
|
/**
|
|
2574
2876
|
* @override
|
|
2575
2877
|
* @param {object} data for update or create
|
|
2576
2878
|
* @returns {this} this
|
|
2577
2879
|
*/
|
|
2578
|
-
insertOrSelect<K extends T.ColumnKeys<this>, C extends T.
|
|
2880
|
+
insertOrSelect<K extends T.ColumnKeys<this>, C extends T.InputOptions<this>>(data: T.InsertInput<K, C>): Model<TS, TR, "createOrSelect">;
|
|
2579
2881
|
/**
|
|
2580
2882
|
*
|
|
2581
2883
|
* @override
|
|
2582
2884
|
* @param {object} data create not exists data
|
|
2583
2885
|
* @returns {this} this
|
|
2584
2886
|
*/
|
|
2585
|
-
createNotExists<K extends T.ColumnKeys<this>, C extends T.
|
|
2887
|
+
createNotExists<K extends T.ColumnKeys<this>, C extends T.InputOptions<this>>(data: T.InsertInput<K, C>): Model<TS, TR, "createNotExists">;
|
|
2586
2888
|
/**
|
|
2587
2889
|
*
|
|
2588
2890
|
* @override
|
|
2589
2891
|
* @param {object} data create not exists data
|
|
2590
2892
|
* @returns {this} this this
|
|
2591
2893
|
*/
|
|
2592
|
-
insertNotExists<K extends T.ColumnKeys<this>, C extends T.
|
|
2894
|
+
insertNotExists<K extends T.ColumnKeys<this>, C extends T.InputOptions<this>>(data: T.InsertInput<K, C>): Model<TS, TR, "createNotExists">;
|
|
2593
2895
|
/**
|
|
2594
2896
|
* @override
|
|
2595
2897
|
* @param {Record<string,any>[]} data create multiple data
|
|
2596
2898
|
* @returns {this} this this
|
|
2597
2899
|
*/
|
|
2598
|
-
createMultiple<K extends T.ColumnKeys<this>, C extends T.
|
|
2900
|
+
createMultiple<K extends T.ColumnKeys<this>, C extends T.InputOptions<this>>(data: T.InsertInput<K, C>[]): Model<TS, TR, "createMany">;
|
|
2599
2901
|
/**
|
|
2600
2902
|
*
|
|
2601
2903
|
* @override
|
|
2602
2904
|
* @param {Record<string,any>[]} data create multiple data
|
|
2603
2905
|
* @returns {this} this
|
|
2604
2906
|
*/
|
|
2605
|
-
createMany<K extends T.ColumnKeys<this>, C extends T.
|
|
2907
|
+
createMany<K extends T.ColumnKeys<this>, C extends T.InputOptions<this>>(data: T.InsertInput<K, C>[]): Model<TS, TR, "createMany">;
|
|
2606
2908
|
/**
|
|
2607
2909
|
*
|
|
2608
2910
|
* @override
|
|
2609
2911
|
* @param {Record<string,any>[]} data create multiple data
|
|
2610
2912
|
* @returns {this} this
|
|
2611
2913
|
*/
|
|
2612
|
-
insertMultiple<K extends T.ColumnKeys<this>, C extends T.
|
|
2914
|
+
insertMultiple<K extends T.ColumnKeys<this>, C extends T.InputOptions<this>>(data: T.InsertInput<K, C>[]): Model<TS, TR, "createMany">;
|
|
2613
2915
|
/**
|
|
2614
2916
|
*
|
|
2615
2917
|
* @override
|
|
2616
2918
|
* @param {Record<string,any>[]} data create multiple data
|
|
2617
2919
|
* @returns {this} this
|
|
2618
2920
|
*/
|
|
2619
|
-
insertMany<K extends T.ColumnKeys<this>, C extends T.
|
|
2921
|
+
insertMany<K extends T.ColumnKeys<this>, C extends T.InputOptions<this>>(data: T.InsertInput<K, C>[]): Model<TS, TR, "createMany">;
|
|
2620
2922
|
/**
|
|
2621
2923
|
* The 'getSchemaModel' method is used get a schema model
|
|
2622
2924
|
* @returns {Record<string, Blueprint> | null} Record<string, Blueprint> | null
|