tspace-mysql 1.9.3 → 1.9.4-beta.2

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.
Files changed (67) hide show
  1. package/README.md +139 -21
  2. package/dist/lib/constants/index.d.ts +1 -1
  3. package/dist/lib/constants/index.js +8 -1
  4. package/dist/lib/constants/index.js.map +1 -1
  5. package/dist/lib/core/Abstracts/AbstractBuilder.d.ts +1 -1
  6. package/dist/lib/core/Abstracts/AbstractBuilder.js +1 -0
  7. package/dist/lib/core/Abstracts/AbstractBuilder.js.map +1 -1
  8. package/dist/lib/core/Blueprint.d.ts +45 -12
  9. package/dist/lib/core/Blueprint.js +43 -2
  10. package/dist/lib/core/Blueprint.js.map +1 -1
  11. package/dist/lib/core/Builder.d.ts +6 -6
  12. package/dist/lib/core/Builder.js +29 -35
  13. package/dist/lib/core/Builder.js.map +1 -1
  14. package/dist/lib/core/Contracts/Audit.d.ts +2 -2
  15. package/dist/lib/core/Contracts/Logger.d.ts +2 -2
  16. package/dist/lib/core/DB.d.ts +137 -6
  17. package/dist/lib/core/DB.js +153 -30
  18. package/dist/lib/core/DB.js.map +1 -1
  19. package/dist/lib/core/Driver/index.d.ts +2 -1
  20. package/dist/lib/core/Driver/index.js +11 -0
  21. package/dist/lib/core/Driver/index.js.map +1 -1
  22. package/dist/lib/core/Driver/mariadb/MariadbDriver.d.ts +4 -1
  23. package/dist/lib/core/Driver/mariadb/MariadbDriver.js +21 -7
  24. package/dist/lib/core/Driver/mariadb/MariadbDriver.js.map +1 -1
  25. package/dist/lib/core/Driver/mongodb/MongodbDriver.d.ts +4 -1
  26. package/dist/lib/core/Driver/mongodb/MongodbDriver.js +8 -6
  27. package/dist/lib/core/Driver/mongodb/MongodbDriver.js.map +1 -1
  28. package/dist/lib/core/Driver/mysql/MysqlDriver.d.ts +4 -1
  29. package/dist/lib/core/Driver/mysql/MysqlDriver.js +35 -7
  30. package/dist/lib/core/Driver/mysql/MysqlDriver.js.map +1 -1
  31. package/dist/lib/core/Driver/postgres/PostgresDriver.d.ts +4 -1
  32. package/dist/lib/core/Driver/postgres/PostgresDriver.js +24 -8
  33. package/dist/lib/core/Driver/postgres/PostgresDriver.js.map +1 -1
  34. package/dist/lib/core/Driver/sqlite/SqliteDriver.d.ts +4 -1
  35. package/dist/lib/core/Driver/sqlite/SqliteDriver.js +14 -6
  36. package/dist/lib/core/Driver/sqlite/SqliteDriver.js.map +1 -1
  37. package/dist/lib/core/Model.d.ts +332 -29
  38. package/dist/lib/core/Model.js +329 -19
  39. package/dist/lib/core/Model.js.map +1 -1
  40. package/dist/lib/core/Pool.d.ts +1 -1
  41. package/dist/lib/core/Pool.js +10 -4
  42. package/dist/lib/core/Pool.js.map +1 -1
  43. package/dist/lib/core/{Queue.d.ts → Queue/index.d.ts} +115 -111
  44. package/dist/lib/core/Queue/index.js +283 -0
  45. package/dist/lib/core/Queue/index.js.map +1 -0
  46. package/dist/lib/core/Queue/types.d.ts +40 -0
  47. package/dist/lib/core/Queue/types.js +3 -0
  48. package/dist/lib/core/Queue/types.js.map +1 -0
  49. package/dist/lib/core/Queue/worker.d.ts +103 -0
  50. package/dist/lib/core/{Queue.js → Queue/worker.js} +261 -311
  51. package/dist/lib/core/Queue/worker.js.map +1 -0
  52. package/dist/lib/core/Repository.d.ts +40 -20
  53. package/dist/lib/core/Repository.js +35 -14
  54. package/dist/lib/core/Repository.js.map +1 -1
  55. package/dist/lib/core/Schema.d.ts +4 -4
  56. package/dist/lib/core/Schema.js +40 -14
  57. package/dist/lib/core/Schema.js.map +1 -1
  58. package/dist/lib/core/UtilityTypes.d.ts +7 -3
  59. package/dist/lib/core/UtilityTypes.js.map +1 -1
  60. package/dist/lib/types/decorator/index.d.ts +3 -0
  61. package/dist/lib/types/index.d.ts +19 -18
  62. package/dist/lib/types/repository/index.d.ts +3 -3
  63. package/dist/lib/utils/index.d.ts +10 -5
  64. package/dist/lib/utils/index.js +42 -9
  65. package/dist/lib/utils/index.js.map +1 -1
  66. package/package.json +3 -5
  67. package/dist/lib/core/Queue.js.map +0 -1
@@ -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 get the functions from the Cache
406
- * @returns {TCacheModel} cache
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,
@@ -1896,6 +2191,7 @@ declare class Model<TS extends Record<string, any> = any, TR = unknown, TA exten
1896
2191
  */
1897
2192
  toTableNameAndColumn(column: string): string;
1898
2193
  where<K extends T.ColumnKeys<this>, V extends T.ColumnValue<this, K>>(column: K, value: V): this;
2194
+ where<K extends T.ColumnKeys<this>, V extends T.ColumnValue<this, K>>(column: K, value: V[]): this;
1899
2195
  where<K extends T.ColumnKeys<this>, V extends T.ColumnValue<this, K>>(column: K, operator: "=" | "<" | ">" | "!=" | "<>" | "<=" | ">=" | "LIKE" | "like", value: V): this;
1900
2196
  where(column: Partial<{
1901
2197
  [K in keyof T.ColumnOptions<this>]: T.ColumnOptions<this>[K];
@@ -1941,8 +2237,8 @@ declare class Model<TS extends Record<string, any> = any, TR = unknown, TA exten
1941
2237
  * @param {Object} columns
1942
2238
  * @returns {this}
1943
2239
  */
1944
- whereObject<K extends T.ColumnKeys<this>, T extends T.ColumnOptions<this>>(columns: {
1945
- [P in K & keyof T]: T[P];
2240
+ whereObject<K extends T.ColumnKeys<this>, CO extends T.ColumnOptions<this>>(columns: {
2241
+ [P in K & keyof CO]: CO[P];
1946
2242
  }): this;
1947
2243
  /**
1948
2244
  * @override
@@ -1991,28 +2287,28 @@ declare class Model<TS extends Record<string, any> = any, TR = unknown, TA exten
1991
2287
  * @param {array} array
1992
2288
  * @returns {this}
1993
2289
  */
1994
- whereIn<K extends T.ColumnKeys<this>>(column: K, array: any[]): this;
2290
+ whereIn<K extends T.ColumnKeys<this>, V extends T.ColumnValue<this, K>>(column: K, array: V[]): this;
1995
2291
  /**
1996
2292
  * @override
1997
2293
  * @param {string} column
1998
2294
  * @param {array} array
1999
2295
  * @returns {this}
2000
2296
  */
2001
- orWhereIn<K extends T.ColumnKeys<this>>(column: K, array: any[]): this;
2297
+ orWhereIn<K extends T.ColumnKeys<this>, V extends T.ColumnValue<this, K>>(column: K, array: V[]): this;
2002
2298
  /**
2003
2299
  * @override
2004
2300
  * @param {string} column
2005
2301
  * @param {array} array
2006
2302
  * @returns {this}
2007
2303
  */
2008
- whereNotIn<K extends T.ColumnKeys<this>>(column: K, array: any[]): this;
2304
+ whereNotIn<K extends T.ColumnKeys<this>, V extends T.ColumnValue<this, K>>(column: K, array: V[]): this;
2009
2305
  /**
2010
2306
  * @override
2011
2307
  * @param {string} column
2012
2308
  * @param {array} array
2013
2309
  * @returns {this}
2014
2310
  */
2015
- orWhereNotIn<K extends T.ColumnKeys<this>>(column: K, array: any[]): this;
2311
+ orWhereNotIn<K extends T.ColumnKeys<this>, V extends T.ColumnValue<this, K>>(column: K, array: V[]): this;
2016
2312
  /**
2017
2313
  * @override
2018
2314
  * @param {string} column
@@ -2381,6 +2677,13 @@ declare class Model<TS extends Record<string, any> = any, TR = unknown, TA exten
2381
2677
  latest?: boolean;
2382
2678
  oldest?: boolean;
2383
2679
  }): string;
2680
+ /**
2681
+ *
2682
+ * @override
2683
+ * @param {Function?} cb callback function return query sql
2684
+ * @returns {AsyncIterable<T.Result<this, K>>}
2685
+ */
2686
+ toAsyncIterable<K>(cb?: Function): AsyncIterable<T.Result<this, K>>;
2384
2687
  /**
2385
2688
  * @override
2386
2689
  * @param {string=} column [column=id]
@@ -2493,27 +2796,27 @@ declare class Model<TS extends Record<string, any> = any, TR = unknown, TA exten
2493
2796
  * @param {object} data for insert
2494
2797
  * @returns {this} this
2495
2798
  */
2496
- insert<K extends T.ColumnKeys<this>, C extends T.ColumnOptions<this>>(data: T.InsertInput<K, C>): Model<TS, TR, "create">;
2799
+ insert<K extends T.ColumnKeys<this>, C extends T.InputOptions<this>>(data: T.InsertInput<K, C>): Model<TS, TR, "create">;
2497
2800
  /**
2498
2801
  * @override
2499
2802
  * @param {object} data for insert
2500
2803
  * @returns {this} this
2501
2804
  */
2502
- create<K extends T.ColumnKeys<this>, C extends T.ColumnOptions<this>>(data: T.InsertInput<K, C>): Model<TS, TR, "create">;
2805
+ create<K extends T.ColumnKeys<this>, C extends T.InputOptions<this>>(data: T.InsertInput<K, C>): Model<TS, TR, "create">;
2503
2806
  /**
2504
2807
  * @override
2505
2808
  * @param {object} data
2506
2809
  * @param {array?} updateNotExists options for except update some records in your ${data}
2507
2810
  * @returns {this} this
2508
2811
  */
2509
- update<K extends T.ColumnKeys<this>, C extends T.ColumnOptions<this>>(data: T.UpdateInput<K, C>, updateNotExists?: T.ColumnKeys<this>[]): Model<TS, TR, "update">;
2812
+ 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
2813
  /**
2511
2814
  * @override
2512
2815
  * @param {object} data
2513
2816
  * @param {array?} updateNotExists options for except update some records in your ${data}
2514
2817
  * @returns {this} this
2515
2818
  */
2516
- updateMany<K extends T.ColumnKeys<this>, C extends T.ColumnOptions<this>>(data: T.UpdateInput<K, C>, updateNotExists?: string[]): Model<TS, TR, "updateMany">;
2819
+ updateMany<K extends T.ColumnKeys<this>, C extends T.InputOptions<this>>(data: T.UpdateInput<K, C>, updateNotExists?: string[]): Model<TS, TR, "updateMany">;
2517
2820
  /**
2518
2821
  *
2519
2822
  * @override
@@ -2526,7 +2829,7 @@ declare class Model<TS extends Record<string, any> = any, TR = unknown, TA exten
2526
2829
  * @property {Record<string,string | number | boolean | null | undefined>} cases.columns
2527
2830
  * @returns {this} this
2528
2831
  */
2529
- updateCases<T extends T.ColumnOptions<this>, K extends keyof T, U extends Model | unknown, M = U extends this ? this : U extends Model ? U : this>(cases: {
2832
+ 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
2833
  condition: ((query: M) => M) | Partial<{
2531
2834
  [P in K & keyof T]: Extract<T[P], Record<string, unknown>> extends never ? T[P] : string;
2532
2835
  }>;
@@ -2539,84 +2842,84 @@ declare class Model<TS extends Record<string, any> = any, TR = unknown, TA exten
2539
2842
  * @param {object} data
2540
2843
  * @returns {this} this
2541
2844
  */
2542
- updateNotExists<K extends T.ColumnKeys<this>, C extends T.ColumnOptions<this>>(data: T.UpdateInput<K, C>): Model<TS, TR, "update">;
2845
+ updateNotExists<K extends T.ColumnKeys<this>, C extends T.InputOptions<this>>(data: T.UpdateInput<K, C>): Model<TS, TR, "update">;
2543
2846
  /**
2544
2847
  * @override
2545
2848
  * @param {object} data for update or create
2546
2849
  * @returns {this} this
2547
2850
  */
2548
- updateOrCreate<K extends T.ColumnKeys<this>, C extends T.ColumnOptions<this>>(data: T.InsertOrUpdateInput<K, C>): Model<TS, TR, "createOrUpdate">;
2851
+ updateOrCreate<K extends T.ColumnKeys<this>, C extends T.InputOptions<this>>(data: T.InsertOrUpdateInput<K, C>): Model<TS, TR, "createOrUpdate">;
2549
2852
  /**
2550
2853
  * @override
2551
2854
  * @param {object} data for update or create
2552
2855
  * @returns {this} this
2553
2856
  */
2554
- updateOrInsert<K extends T.ColumnKeys<this>, C extends T.ColumnOptions<this>>(data: T.InsertOrUpdateInput<K, C>): Model<TS, TR, "createOrUpdate">;
2857
+ updateOrInsert<K extends T.ColumnKeys<this>, C extends T.InputOptions<this>>(data: T.InsertOrUpdateInput<K, C>): Model<TS, TR, "createOrUpdate">;
2555
2858
  /**
2556
2859
  * @override
2557
2860
  * @param {object} data for update or create
2558
2861
  * @returns {this} this
2559
2862
  */
2560
- insertOrUpdate<K extends T.ColumnKeys<this>, C extends T.ColumnOptions<this>>(data: T.InsertOrUpdateInput<K, C>): Model<TS, TR, "createOrUpdate">;
2863
+ insertOrUpdate<K extends T.ColumnKeys<this>, C extends T.InputOptions<this>>(data: T.InsertOrUpdateInput<K, C>): Model<TS, TR, "createOrUpdate">;
2561
2864
  /**
2562
2865
  * @override
2563
2866
  * @param {object} data for update or create
2564
2867
  * @returns {this} this
2565
2868
  */
2566
- createOrUpdate<K extends T.ColumnKeys<this>, C extends T.ColumnOptions<this>>(data: T.InsertOrUpdateInput<K, C>): Model<TS, TR, "createOrUpdate">;
2869
+ createOrUpdate<K extends T.ColumnKeys<this>, C extends T.InputOptions<this>>(data: T.InsertOrUpdateInput<K, C>): Model<TS, TR, "createOrUpdate">;
2567
2870
  /**
2568
2871
  * @override
2569
2872
  * @param {object} data for create
2570
2873
  * @returns {this} this
2571
2874
  */
2572
- createOrSelect<K extends T.ColumnKeys<this>, C extends T.ColumnOptions<this>>(data: T.InsertInput<K, C>): Model<TS, TR, "createOrSelect">;
2875
+ createOrSelect<K extends T.ColumnKeys<this>, C extends T.InputOptions<this>>(data: T.InsertInput<K, C>): Model<TS, TR, "createOrSelect">;
2573
2876
  /**
2574
2877
  * @override
2575
2878
  * @param {object} data for update or create
2576
2879
  * @returns {this} this
2577
2880
  */
2578
- insertOrSelect<K extends T.ColumnKeys<this>, C extends T.ColumnOptions<this>>(data: T.InsertInput<K, C>): Model<TS, TR, "createOrSelect">;
2881
+ insertOrSelect<K extends T.ColumnKeys<this>, C extends T.InputOptions<this>>(data: T.InsertInput<K, C>): Model<TS, TR, "createOrSelect">;
2579
2882
  /**
2580
2883
  *
2581
2884
  * @override
2582
2885
  * @param {object} data create not exists data
2583
2886
  * @returns {this} this
2584
2887
  */
2585
- createNotExists<K extends T.ColumnKeys<this>, C extends T.ColumnOptions<this>>(data: T.InsertInput<K, C>): Model<TS, TR, "createNotExists">;
2888
+ createNotExists<K extends T.ColumnKeys<this>, C extends T.InputOptions<this>>(data: T.InsertInput<K, C>): Model<TS, TR, "createNotExists">;
2586
2889
  /**
2587
2890
  *
2588
2891
  * @override
2589
2892
  * @param {object} data create not exists data
2590
2893
  * @returns {this} this this
2591
2894
  */
2592
- insertNotExists<K extends T.ColumnKeys<this>, C extends T.ColumnOptions<this>>(data: T.InsertInput<K, C>): Model<TS, TR, "createNotExists">;
2895
+ insertNotExists<K extends T.ColumnKeys<this>, C extends T.InputOptions<this>>(data: T.InsertInput<K, C>): Model<TS, TR, "createNotExists">;
2593
2896
  /**
2594
2897
  * @override
2595
2898
  * @param {Record<string,any>[]} data create multiple data
2596
2899
  * @returns {this} this this
2597
2900
  */
2598
- createMultiple<K extends T.ColumnKeys<this>, C extends T.ColumnOptions<this>>(data: T.InsertInput<K, C>[]): Model<TS, TR, "createMany">;
2901
+ createMultiple<K extends T.ColumnKeys<this>, C extends T.InputOptions<this>>(data: T.InsertInput<K, C>[]): Model<TS, TR, "createMany">;
2599
2902
  /**
2600
2903
  *
2601
2904
  * @override
2602
2905
  * @param {Record<string,any>[]} data create multiple data
2603
2906
  * @returns {this} this
2604
2907
  */
2605
- createMany<K extends T.ColumnKeys<this>, C extends T.ColumnOptions<this>>(data: T.InsertInput<K, C>[]): Model<TS, TR, "createMany">;
2908
+ createMany<K extends T.ColumnKeys<this>, C extends T.InputOptions<this>>(data: T.InsertInput<K, C>[]): Model<TS, TR, "createMany">;
2606
2909
  /**
2607
2910
  *
2608
2911
  * @override
2609
2912
  * @param {Record<string,any>[]} data create multiple data
2610
2913
  * @returns {this} this
2611
2914
  */
2612
- insertMultiple<K extends T.ColumnKeys<this>, C extends T.ColumnOptions<this>>(data: T.InsertInput<K, C>[]): Model<TS, TR, "createMany">;
2915
+ insertMultiple<K extends T.ColumnKeys<this>, C extends T.InputOptions<this>>(data: T.InsertInput<K, C>[]): Model<TS, TR, "createMany">;
2613
2916
  /**
2614
2917
  *
2615
2918
  * @override
2616
2919
  * @param {Record<string,any>[]} data create multiple data
2617
2920
  * @returns {this} this
2618
2921
  */
2619
- insertMany<K extends T.ColumnKeys<this>, C extends T.ColumnOptions<this>>(data: T.InsertInput<K, C>[]): Model<TS, TR, "createMany">;
2922
+ insertMany<K extends T.ColumnKeys<this>, C extends T.InputOptions<this>>(data: T.InsertInput<K, C>[]): Model<TS, TR, "createMany">;
2620
2923
  /**
2621
2924
  * The 'getSchemaModel' method is used get a schema model
2622
2925
  * @returns {Record<string, Blueprint> | null} Record<string, Blueprint> | null