tspace-mysql 1.9.3-beta.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 +16 -2
- package/dist/lib/core/Abstracts/AbstractBuilder.d.ts +1 -0
- package/dist/lib/core/Abstracts/AbstractBuilder.js +1 -0
- package/dist/lib/core/Abstracts/AbstractBuilder.js.map +1 -1
- package/dist/lib/core/Builder.d.ts +1 -1
- package/dist/lib/core/Builder.js +10 -4
- package/dist/lib/core/Builder.js.map +1 -1
- package/dist/lib/core/DB.d.ts +137 -6
- package/dist/lib/core/DB.js +152 -29
- 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 +163 -1
- package/dist/lib/core/Model.js +177 -5
- 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/index.d.ts +1 -1
- package/dist/lib/core/Queue/index.js +2 -1
- package/dist/lib/core/Queue/index.js.map +1 -1
- package/dist/lib/core/Queue/types.d.ts +3 -2
- package/dist/lib/core/Queue/worker.d.ts +2 -1
- package/dist/lib/core/Queue/worker.js +136 -60
- package/dist/lib/core/Queue/worker.js.map +1 -1
- package/dist/lib/core/Repository.js.map +1 -1
- package/dist/lib/types/index.d.ts +3 -0
- package/dist/lib/utils/index.d.ts +4 -2
- package/dist/lib/utils/index.js +37 -5
- package/dist/lib/utils/index.js.map +1 -1
- package/package.json +3 -5
package/dist/lib/core/Model.js
CHANGED
|
@@ -443,12 +443,14 @@ class Model extends AbstractModel_1.AbstractModel {
|
|
|
443
443
|
* @example
|
|
444
444
|
* import { User } from '../Models/User'
|
|
445
445
|
*
|
|
446
|
-
* const users = await User.
|
|
446
|
+
* const users = await User.toArray('id',{
|
|
447
447
|
* where : {
|
|
448
448
|
* id: 1
|
|
449
449
|
* }
|
|
450
450
|
* })
|
|
451
451
|
*
|
|
452
|
+
* // [1]
|
|
453
|
+
*
|
|
452
454
|
*/
|
|
453
455
|
static toArray(column, options = {}) {
|
|
454
456
|
return (0, Repository_1.Repository)(this).toArray(column, options);
|
|
@@ -495,6 +497,176 @@ class Model extends AbstractModel_1.AbstractModel {
|
|
|
495
497
|
static async *toAsyncIterable(options = {}) {
|
|
496
498
|
return yield* (0, Repository_1.Repository)(this).toAsyncIterable(options);
|
|
497
499
|
}
|
|
500
|
+
/**
|
|
501
|
+
* The 'count' method is used to retrieve the total number of records that match the specified query conditions.
|
|
502
|
+
*
|
|
503
|
+
* It returns an integer representing the count of records.
|
|
504
|
+
* @static
|
|
505
|
+
* @type {?object} options
|
|
506
|
+
* @property {?object} options.select
|
|
507
|
+
* @property {?object} options.except
|
|
508
|
+
* @property {?object[]} options.orderBy
|
|
509
|
+
* @property {?string[]} options.groupBy
|
|
510
|
+
* @property {?string} options.having
|
|
511
|
+
* @property {?number} options.limit
|
|
512
|
+
* @property {?number} options.offset
|
|
513
|
+
* @property {?object} options.where
|
|
514
|
+
* @property {?string[]} options.whereRaw
|
|
515
|
+
* @property {?object} options.whereQuery
|
|
516
|
+
* @property {?{condition,callback}} options.when
|
|
517
|
+
* @property {?{localKey , referenceKey}[]} options.join
|
|
518
|
+
* @property {?{localKey , referenceKey}[]} options.rightJoin
|
|
519
|
+
* @property {?{localKey , referenceKey}[]} options.leftJoin
|
|
520
|
+
* @property {?boolean} options.debug
|
|
521
|
+
* @property {?number} options.page
|
|
522
|
+
*
|
|
523
|
+
* @example
|
|
524
|
+
* import { User } from '../Models/User'
|
|
525
|
+
*
|
|
526
|
+
* const count = await User.count('id',{
|
|
527
|
+
* where : {
|
|
528
|
+
* id: 1
|
|
529
|
+
* }
|
|
530
|
+
* })
|
|
531
|
+
*
|
|
532
|
+
* // 1
|
|
533
|
+
*
|
|
534
|
+
*/
|
|
535
|
+
static count(column, options = {}) {
|
|
536
|
+
return (0, Repository_1.Repository)(this).count(column, options);
|
|
537
|
+
}
|
|
538
|
+
/**
|
|
539
|
+
* The 'sum' method is used to retrieve the total number of records that match the specified query conditions.
|
|
540
|
+
*
|
|
541
|
+
* It returns an integer representing the sum of records.
|
|
542
|
+
* @static
|
|
543
|
+
* @type {?object} options
|
|
544
|
+
* @property {?object} options.select
|
|
545
|
+
* @property {?object} options.except
|
|
546
|
+
* @property {?object[]} options.orderBy
|
|
547
|
+
* @property {?string[]} options.groupBy
|
|
548
|
+
* @property {?string} options.having
|
|
549
|
+
* @property {?number} options.limit
|
|
550
|
+
* @property {?number} options.offset
|
|
551
|
+
* @property {?object} options.where
|
|
552
|
+
* @property {?string[]} options.whereRaw
|
|
553
|
+
* @property {?object} options.whereQuery
|
|
554
|
+
* @property {?{condition,callback}} options.when
|
|
555
|
+
* @property {?{localKey , referenceKey}[]} options.join
|
|
556
|
+
* @property {?{localKey , referenceKey}[]} options.rightJoin
|
|
557
|
+
* @property {?{localKey , referenceKey}[]} options.leftJoin
|
|
558
|
+
* @property {?boolean} options.debug
|
|
559
|
+
* @property {?number} options.page
|
|
560
|
+
*
|
|
561
|
+
* @example
|
|
562
|
+
* import { User } from '../Models/User'
|
|
563
|
+
*
|
|
564
|
+
* const sum = await User.sum('id')
|
|
565
|
+
*
|
|
566
|
+
*
|
|
567
|
+
*/
|
|
568
|
+
static sum(column, options = {}) {
|
|
569
|
+
return (0, Repository_1.Repository)(this).sum(column, options);
|
|
570
|
+
}
|
|
571
|
+
/**
|
|
572
|
+
* The 'avg' method is used to retrieve the total number of records that match the specified query conditions.
|
|
573
|
+
*
|
|
574
|
+
* It returns an integer representing the avg of records.
|
|
575
|
+
* @static
|
|
576
|
+
* @type {?object} options
|
|
577
|
+
* @property {?object} options.select
|
|
578
|
+
* @property {?object} options.except
|
|
579
|
+
* @property {?object[]} options.orderBy
|
|
580
|
+
* @property {?string[]} options.groupBy
|
|
581
|
+
* @property {?string} options.having
|
|
582
|
+
* @property {?number} options.limit
|
|
583
|
+
* @property {?number} options.offset
|
|
584
|
+
* @property {?object} options.where
|
|
585
|
+
* @property {?string[]} options.whereRaw
|
|
586
|
+
* @property {?object} options.whereQuery
|
|
587
|
+
* @property {?{condition,callback}} options.when
|
|
588
|
+
* @property {?{localKey , referenceKey}[]} options.join
|
|
589
|
+
* @property {?{localKey , referenceKey}[]} options.rightJoin
|
|
590
|
+
* @property {?{localKey , referenceKey}[]} options.leftJoin
|
|
591
|
+
* @property {?boolean} options.debug
|
|
592
|
+
* @property {?number} options.page
|
|
593
|
+
*
|
|
594
|
+
* @example
|
|
595
|
+
* import { User } from '../Models/User'
|
|
596
|
+
*
|
|
597
|
+
* const avg = await User.avg('id')
|
|
598
|
+
*
|
|
599
|
+
*
|
|
600
|
+
*/
|
|
601
|
+
static avg(column, options = {}) {
|
|
602
|
+
return (0, Repository_1.Repository)(this).avg(column, options);
|
|
603
|
+
}
|
|
604
|
+
/**
|
|
605
|
+
* The 'max' method is used to retrieve the total number of records that match the specified query conditions.
|
|
606
|
+
*
|
|
607
|
+
* It returns an integer representing the max of records.
|
|
608
|
+
* @static
|
|
609
|
+
* @type {?object} options
|
|
610
|
+
* @property {?object} options.select
|
|
611
|
+
* @property {?object} options.except
|
|
612
|
+
* @property {?object[]} options.orderBy
|
|
613
|
+
* @property {?string[]} options.groupBy
|
|
614
|
+
* @property {?string} options.having
|
|
615
|
+
* @property {?number} options.limit
|
|
616
|
+
* @property {?number} options.offset
|
|
617
|
+
* @property {?object} options.where
|
|
618
|
+
* @property {?string[]} options.whereRaw
|
|
619
|
+
* @property {?object} options.whereQuery
|
|
620
|
+
* @property {?{condition,callback}} options.when
|
|
621
|
+
* @property {?{localKey , referenceKey}[]} options.join
|
|
622
|
+
* @property {?{localKey , referenceKey}[]} options.rightJoin
|
|
623
|
+
* @property {?{localKey , referenceKey}[]} options.leftJoin
|
|
624
|
+
* @property {?boolean} options.debug
|
|
625
|
+
* @property {?number} options.page
|
|
626
|
+
*
|
|
627
|
+
* @example
|
|
628
|
+
* import { User } from '../Models/User'
|
|
629
|
+
*
|
|
630
|
+
* const max = await User.max('id')
|
|
631
|
+
*
|
|
632
|
+
*
|
|
633
|
+
*/
|
|
634
|
+
static max(column, options = {}) {
|
|
635
|
+
return (0, Repository_1.Repository)(this).max(column, options);
|
|
636
|
+
}
|
|
637
|
+
/**
|
|
638
|
+
* The 'min' method is used to retrieve the total number of records that match the specified query conditions.
|
|
639
|
+
*
|
|
640
|
+
* It returns an integer representing the min of records.
|
|
641
|
+
* @static
|
|
642
|
+
* @type {?object} options
|
|
643
|
+
* @property {?object} options.select
|
|
644
|
+
* @property {?object} options.except
|
|
645
|
+
* @property {?object[]} options.orderBy
|
|
646
|
+
* @property {?string[]} options.groupBy
|
|
647
|
+
* @property {?string} options.having
|
|
648
|
+
* @property {?number} options.limit
|
|
649
|
+
* @property {?number} options.offset
|
|
650
|
+
* @property {?object} options.where
|
|
651
|
+
* @property {?string[]} options.whereRaw
|
|
652
|
+
* @property {?object} options.whereQuery
|
|
653
|
+
* @property {?{condition,callback}} options.when
|
|
654
|
+
* @property {?{localKey , referenceKey}[]} options.join
|
|
655
|
+
* @property {?{localKey , referenceKey}[]} options.rightJoin
|
|
656
|
+
* @property {?{localKey , referenceKey}[]} options.leftJoin
|
|
657
|
+
* @property {?boolean} options.debug
|
|
658
|
+
* @property {?number} options.page
|
|
659
|
+
*
|
|
660
|
+
* @example
|
|
661
|
+
* import { User } from '../Models/User'
|
|
662
|
+
*
|
|
663
|
+
* const min = await User.min('id')
|
|
664
|
+
*
|
|
665
|
+
*
|
|
666
|
+
*/
|
|
667
|
+
static min(column, options = {}) {
|
|
668
|
+
return (0, Repository_1.Repository)(this).min(column, options);
|
|
669
|
+
}
|
|
498
670
|
/**
|
|
499
671
|
* The 'create' method is used to insert a new record into a database table associated.
|
|
500
672
|
*
|
|
@@ -4913,7 +5085,7 @@ class Model extends AbstractModel_1.AbstractModel {
|
|
|
4913
5085
|
columns[key] = `( ${updateColumns[key].join(" ")} )`;
|
|
4914
5086
|
}
|
|
4915
5087
|
const keyValue = Object.entries(columns).map(([column, value]) => {
|
|
4916
|
-
value = this.$utils.
|
|
5088
|
+
value = this.$utils.escapePayload(value);
|
|
4917
5089
|
return `${this.bindColumn(column)} = ${value == null || value === this.$constants("NULL")
|
|
4918
5090
|
? this.$constants("NULL")
|
|
4919
5091
|
: this.$utils.transfromValueHasRaw(value)}`;
|
|
@@ -6116,7 +6288,7 @@ class Model extends AbstractModel_1.AbstractModel {
|
|
|
6116
6288
|
});
|
|
6117
6289
|
}
|
|
6118
6290
|
const keyValue = Object.entries(objects).map(([column, value]) => {
|
|
6119
|
-
value = this.$utils.
|
|
6291
|
+
value = this.$utils.escapePayload(value);
|
|
6120
6292
|
return `${this.bindColumn(column)} = ${value == null || value === this.$constants("NULL")
|
|
6121
6293
|
? this.$constants("NULL")
|
|
6122
6294
|
: this.$utils.transfromValueHasRaw(value)}`;
|
|
@@ -6159,7 +6331,7 @@ class Model extends AbstractModel_1.AbstractModel {
|
|
|
6159
6331
|
}
|
|
6160
6332
|
const columns = Object.keys(data).map((c) => `\`${this._valuePattern(c).replace(/\`/g, "")}\``);
|
|
6161
6333
|
const values = Object.values(data).map((value) => {
|
|
6162
|
-
value = this.$utils.
|
|
6334
|
+
value = this.$utils.escapePayload(value);
|
|
6163
6335
|
if (this.$utils.typeOf(value) === "object" ||
|
|
6164
6336
|
this.$utils.typeOf(value) === "array") {
|
|
6165
6337
|
value = JSON.stringify(value);
|
|
@@ -6214,7 +6386,7 @@ class Model extends AbstractModel_1.AbstractModel {
|
|
|
6214
6386
|
columns = [`\`${uuidFormat}\``, ...columns];
|
|
6215
6387
|
}
|
|
6216
6388
|
const v = Object.values(objects).map((value) => {
|
|
6217
|
-
value = this.$utils.
|
|
6389
|
+
value = this.$utils.escapePayload(value);
|
|
6218
6390
|
if (this.$utils.typeOf(value) === "object" ||
|
|
6219
6391
|
this.$utils.typeOf(value) === "array") {
|
|
6220
6392
|
value = JSON.stringify(value);
|