tspace-mysql 1.5.2 → 1.5.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/README.md +8 -8
- package/build/lib/connection/options.js +1 -1
- package/build/lib/constants/index.d.ts +1 -3
- package/build/lib/constants/index.js +0 -96
- package/build/lib/core/Abstracts/AbstractBuilder.d.ts +1 -1
- package/build/lib/core/Abstracts/AbstractBuilder.js +1 -4
- package/build/lib/core/Builder.d.ts +1 -1
- package/build/lib/core/Builder.js +41 -18
- package/build/lib/core/DB.js +1 -1
- package/build/lib/core/Handlers/State.d.ts +2 -2
- package/build/lib/core/Handlers/State.js +126 -12
- package/build/lib/core/Model.d.ts +77 -71
- package/build/lib/core/Model.js +64 -18
- package/build/lib/core/Type.d.ts +55 -1
- package/package.json +1 -1
|
@@ -11,7 +11,7 @@ import { Relation, Pagination, RelationQuery, ValidateSchema, GlobalSetting } fr
|
|
|
11
11
|
* const users = await new User().findMany()
|
|
12
12
|
* console.log(users)
|
|
13
13
|
*/
|
|
14
|
-
declare class Model<
|
|
14
|
+
declare class Model<TSchema extends Record<string, Blueprint | string | number | Date> = any, TRelation = any> extends AbstractModel<TSchema, TRelation> {
|
|
15
15
|
constructor();
|
|
16
16
|
/**
|
|
17
17
|
* The 'global' method is used setting global variables in models.
|
|
@@ -413,7 +413,7 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
|
|
|
413
413
|
* @param {string} column
|
|
414
414
|
* @return {string}
|
|
415
415
|
*/
|
|
416
|
-
column<K extends keyof
|
|
416
|
+
column<K extends keyof TSchema>(column: K): K;
|
|
417
417
|
/**
|
|
418
418
|
* The "beforeCreatingTable" method is used exection function when creating the table.
|
|
419
419
|
* @param {Function} fn functions for executing before creating the table
|
|
@@ -444,21 +444,21 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
|
|
|
444
444
|
* @param {Function} callback query callback
|
|
445
445
|
* @return {this} this
|
|
446
446
|
*/
|
|
447
|
-
protected buildMethodRelation<K extends keyof
|
|
447
|
+
protected buildMethodRelation<K extends keyof TRelation>(name: K, callback?: Function): this;
|
|
448
448
|
/**
|
|
449
449
|
*
|
|
450
450
|
* @override
|
|
451
451
|
* @param {string[]} ...columns
|
|
452
452
|
* @return {this} this
|
|
453
453
|
*/
|
|
454
|
-
select<K extends Extract<keyof
|
|
454
|
+
select<K extends Extract<keyof TSchema, string> | `${string}.${string}` | '*'>(...columns: K[]): this;
|
|
455
455
|
/**
|
|
456
456
|
*
|
|
457
457
|
* @override
|
|
458
458
|
* @param {...string} columns
|
|
459
459
|
* @return {this} this
|
|
460
460
|
*/
|
|
461
|
-
except<K extends Extract<keyof
|
|
461
|
+
except<K extends Extract<keyof TSchema, string> | `${string}.${string}`>(...columns: K[]): this;
|
|
462
462
|
/**
|
|
463
463
|
*
|
|
464
464
|
* @override
|
|
@@ -472,28 +472,28 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
|
|
|
472
472
|
* @param {string?} order by default order = 'asc' but you can used 'asc' or 'desc'
|
|
473
473
|
* @return {this}
|
|
474
474
|
*/
|
|
475
|
-
orderBy<K extends Extract<keyof
|
|
475
|
+
orderBy<K extends Extract<keyof TSchema, string> | `${string}.${string}`>(column: K, order?: 'ASC' | 'DESC'): this;
|
|
476
476
|
/**
|
|
477
477
|
*
|
|
478
478
|
* @override
|
|
479
479
|
* @param {string?} columns [column=id]
|
|
480
480
|
* @return {this}
|
|
481
481
|
*/
|
|
482
|
-
latest<K extends Extract<keyof
|
|
482
|
+
latest<K extends Extract<keyof TSchema, string> | `${string}.${string}`>(...columns: K[]): this;
|
|
483
483
|
/**
|
|
484
484
|
*
|
|
485
485
|
* @override
|
|
486
486
|
* @param {string?} columns [column=id]
|
|
487
487
|
* @return {this}
|
|
488
488
|
*/
|
|
489
|
-
oldest<K extends Extract<keyof
|
|
489
|
+
oldest<K extends Extract<keyof TSchema, string> | `${string}.${string}`>(...columns: K[]): this;
|
|
490
490
|
/**
|
|
491
491
|
*
|
|
492
492
|
* @override
|
|
493
493
|
* @param {string?} columns [column=id]
|
|
494
494
|
* @return {this}
|
|
495
495
|
*/
|
|
496
|
-
groupBy<K extends Extract<keyof
|
|
496
|
+
groupBy<K extends Extract<keyof TSchema, string> | `${string}.${string}`>(...columns: K[]): this;
|
|
497
497
|
/**
|
|
498
498
|
* @override
|
|
499
499
|
* @param {string} column
|
|
@@ -639,7 +639,7 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
|
|
|
639
639
|
* await new User().relations('posts').findMany()
|
|
640
640
|
*
|
|
641
641
|
*/
|
|
642
|
-
with<K extends keyof
|
|
642
|
+
with<K extends keyof TRelation>(...nameRelations: K[]): this;
|
|
643
643
|
/**
|
|
644
644
|
* The 'withAll' method is used to eager load related (relations) data when retrieving records from a database.
|
|
645
645
|
*
|
|
@@ -648,7 +648,7 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
|
|
|
648
648
|
* @param {...string} nameRelations if data exists return blank
|
|
649
649
|
* @return {this} this
|
|
650
650
|
*/
|
|
651
|
-
withAll<K extends keyof
|
|
651
|
+
withAll<K extends keyof TRelation>(...nameRelations: K[]): this;
|
|
652
652
|
/**
|
|
653
653
|
* The 'withAll' method is used to eager load related (relations) data when retrieving records from a database.
|
|
654
654
|
*
|
|
@@ -657,7 +657,7 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
|
|
|
657
657
|
* @param {...string} nameRelations if data exists return blank
|
|
658
658
|
* @return {this} this
|
|
659
659
|
*/
|
|
660
|
-
withCount<K extends keyof
|
|
660
|
+
withCount<K extends keyof TRelation>(...nameRelations: K[]): this;
|
|
661
661
|
/**
|
|
662
662
|
* The 'withTrashed' method is used to eager load related (relations) data when retrieving records from a database.
|
|
663
663
|
*
|
|
@@ -666,7 +666,7 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
|
|
|
666
666
|
* @param {...string} nameRelations if data exists return blank
|
|
667
667
|
* @return {this} this
|
|
668
668
|
*/
|
|
669
|
-
withTrashed<K extends keyof
|
|
669
|
+
withTrashed<K extends keyof TRelation>(...nameRelations: K[]): this;
|
|
670
670
|
/**
|
|
671
671
|
* The 'withExists' method is used to eager load related (relations) data when retrieving records from a database.
|
|
672
672
|
*
|
|
@@ -693,7 +693,7 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
|
|
|
693
693
|
* // use with for results of relationship if relations is exists
|
|
694
694
|
* await new User().relationsExists('posts').findMany()
|
|
695
695
|
*/
|
|
696
|
-
withExists<K extends keyof
|
|
696
|
+
withExists<K extends keyof TRelation>(...nameRelations: K[]): this;
|
|
697
697
|
/**
|
|
698
698
|
*
|
|
699
699
|
* Use relations in registry of model return only exists result of relation query
|
|
@@ -718,7 +718,7 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
|
|
|
718
718
|
* await new User().has('posts').findMany()
|
|
719
719
|
* @return {this} this
|
|
720
720
|
*/
|
|
721
|
-
has<K extends keyof
|
|
721
|
+
has<K extends keyof TRelation>(...nameRelations: K[]): this;
|
|
722
722
|
/**
|
|
723
723
|
*
|
|
724
724
|
* The 'withQuery' method is particularly useful when you want to filter or add conditions records based on related data.
|
|
@@ -767,7 +767,7 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
|
|
|
767
767
|
* .findMany()
|
|
768
768
|
* @return {this} this
|
|
769
769
|
*/
|
|
770
|
-
withQuery<K extends keyof
|
|
770
|
+
withQuery<K extends keyof TRelation, TModel extends Model>(nameRelation: K, callback: (query: TModel) => TModel): this;
|
|
771
771
|
/**
|
|
772
772
|
*
|
|
773
773
|
* Use relations in registry of model return result of relation query
|
|
@@ -817,7 +817,7 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
|
|
|
817
817
|
* await new User().relationsExists('posts').findMany()
|
|
818
818
|
* @return {this} this
|
|
819
819
|
*/
|
|
820
|
-
relationsExists<K extends keyof
|
|
820
|
+
relationsExists<K extends keyof TRelation>(...nameRelations: K[]): this;
|
|
821
821
|
/**
|
|
822
822
|
*
|
|
823
823
|
* Use relation '${name}' registry of model return callback this query model
|
|
@@ -864,21 +864,21 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
|
|
|
864
864
|
* .findMany()
|
|
865
865
|
* @return {this} this
|
|
866
866
|
*/
|
|
867
|
-
relationQuery<K extends keyof
|
|
867
|
+
relationQuery<K extends keyof TRelation, T extends Model>(nameRelation: K, callback: (query: T) => T): this;
|
|
868
868
|
/**
|
|
869
869
|
*
|
|
870
870
|
* Use relations in registry of model return ignore soft deleted
|
|
871
871
|
* @param {...string} nameRelations if data exists return blank
|
|
872
872
|
* @return {this} this
|
|
873
873
|
*/
|
|
874
|
-
relationsAll<K extends keyof
|
|
874
|
+
relationsAll<K extends keyof TRelation>(...nameRelations: K[]): this;
|
|
875
875
|
/**
|
|
876
876
|
*
|
|
877
877
|
* Use relations in registry of model return only in trash (soft delete)
|
|
878
878
|
* @param {...string} nameRelations if data exists return blank
|
|
879
879
|
* @return {this} this
|
|
880
880
|
*/
|
|
881
|
-
relationsTrashed<K extends keyof
|
|
881
|
+
relationsTrashed<K extends keyof TRelation>(...nameRelations: K[]): this;
|
|
882
882
|
/**
|
|
883
883
|
* The 'hasOne' relationship defines a one-to-one relationship between two database tables.
|
|
884
884
|
*
|
|
@@ -895,7 +895,7 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
|
|
|
895
895
|
* @property {string} relation.freezeTable
|
|
896
896
|
* @return {this} this
|
|
897
897
|
*/
|
|
898
|
-
protected hasOne<K extends keyof
|
|
898
|
+
protected hasOne<K extends keyof TRelation>({ name, as, model, localKey, foreignKey, freezeTable }: Relation<K>): this;
|
|
899
899
|
/**
|
|
900
900
|
* The 'hasMany' relationship defines a one-to-many relationship between two database tables.
|
|
901
901
|
*
|
|
@@ -912,7 +912,7 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
|
|
|
912
912
|
* @property {string} relation.freezeTable
|
|
913
913
|
* @return {this} this
|
|
914
914
|
*/
|
|
915
|
-
protected hasMany<K extends keyof
|
|
915
|
+
protected hasMany<K extends keyof TRelation>({ name, as, model, localKey, foreignKey, freezeTable }: Relation<K>): this;
|
|
916
916
|
/**
|
|
917
917
|
* The 'belongsTo' relationship defines a one-to-one or many-to-one relationship between two database tables.
|
|
918
918
|
*
|
|
@@ -929,7 +929,7 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
|
|
|
929
929
|
* @property {string} relation.freezeTable
|
|
930
930
|
* @return {this} this
|
|
931
931
|
*/
|
|
932
|
-
protected belongsTo<K extends keyof
|
|
932
|
+
protected belongsTo<K extends keyof TRelation>({ name, as, model, localKey, foreignKey, freezeTable }: Relation<K>): this;
|
|
933
933
|
/**
|
|
934
934
|
* The 'belongsToMany' relationship defines a many-to-many relationship between two database tables.
|
|
935
935
|
*
|
|
@@ -949,7 +949,7 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
|
|
|
949
949
|
* @property {class?} relation.modelPivot model for pivot
|
|
950
950
|
* @return {this} this
|
|
951
951
|
*/
|
|
952
|
-
protected belongsToMany<K extends keyof
|
|
952
|
+
protected belongsToMany<K extends keyof TRelation>({ name, as, model, localKey, foreignKey, freezeTable, pivot, oldVersion, modelPivot }: Relation<K>): this;
|
|
953
953
|
/**
|
|
954
954
|
* The 'hasOneBuilder' method is useful for creating 'hasOne' relationship to function
|
|
955
955
|
*
|
|
@@ -1047,7 +1047,7 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
|
|
|
1047
1047
|
* @param {any?} value
|
|
1048
1048
|
* @return {this} this
|
|
1049
1049
|
*/
|
|
1050
|
-
where<K extends Extract<keyof
|
|
1050
|
+
where<K extends Extract<keyof TSchema, string> | `${string}.${string}`>(column: K | Record<string, any>, operator?: any, value?: any): this;
|
|
1051
1051
|
/**
|
|
1052
1052
|
* @override
|
|
1053
1053
|
* @param {string} column
|
|
@@ -1055,13 +1055,13 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
|
|
|
1055
1055
|
* @param {any?} value
|
|
1056
1056
|
* @return {this}
|
|
1057
1057
|
*/
|
|
1058
|
-
orWhere<K extends Extract<keyof
|
|
1058
|
+
orWhere<K extends Extract<keyof TSchema, string> | `${string}.${string}`>(column: K, operator?: any, value?: any): this;
|
|
1059
1059
|
/**
|
|
1060
1060
|
* @override
|
|
1061
1061
|
* @param {Object} columns
|
|
1062
1062
|
* @return {this}
|
|
1063
1063
|
*/
|
|
1064
|
-
whereObject(columns: Record<
|
|
1064
|
+
whereObject<K extends keyof TSchema>(columns: Record<K, any>): this;
|
|
1065
1065
|
/**
|
|
1066
1066
|
* @override
|
|
1067
1067
|
* @param {string} column
|
|
@@ -1071,7 +1071,7 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
|
|
|
1071
1071
|
* @property {string?} property.operator
|
|
1072
1072
|
* @return {this}
|
|
1073
1073
|
*/
|
|
1074
|
-
whereJSON<K extends Extract<keyof
|
|
1074
|
+
whereJSON<K extends Extract<keyof TSchema, string> | `${string}.${string}`>(column: K, { key, value, operator }: {
|
|
1075
1075
|
key: string;
|
|
1076
1076
|
value: string;
|
|
1077
1077
|
operator?: string;
|
|
@@ -1089,108 +1089,108 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
|
|
|
1089
1089
|
* @param {array} array
|
|
1090
1090
|
* @return {this}
|
|
1091
1091
|
*/
|
|
1092
|
-
whereIn<K extends Extract<keyof
|
|
1092
|
+
whereIn<K extends Extract<keyof TSchema, string> | `${string}.${string}`>(column: K, array: any[]): this;
|
|
1093
1093
|
/**
|
|
1094
1094
|
* @override
|
|
1095
1095
|
* @param {string} column
|
|
1096
1096
|
* @param {array} array
|
|
1097
1097
|
* @return {this}
|
|
1098
1098
|
*/
|
|
1099
|
-
orWhereIn<K extends Extract<keyof
|
|
1099
|
+
orWhereIn<K extends Extract<keyof TSchema, string> | `${string}.${string}`>(column: K, array: any[]): this;
|
|
1100
1100
|
/**
|
|
1101
1101
|
* @override
|
|
1102
1102
|
* @param {string} column
|
|
1103
1103
|
* @param {array} array
|
|
1104
1104
|
* @return {this}
|
|
1105
1105
|
*/
|
|
1106
|
-
whereNotIn<K extends Extract<keyof
|
|
1106
|
+
whereNotIn<K extends Extract<keyof TSchema, string> | `${string}.${string}`>(column: K, array: any[]): this;
|
|
1107
1107
|
/**
|
|
1108
1108
|
* @override
|
|
1109
1109
|
* @param {string} column
|
|
1110
1110
|
* @param {array} array
|
|
1111
1111
|
* @return {this}
|
|
1112
1112
|
*/
|
|
1113
|
-
orWhereNotIn<K extends Extract<keyof
|
|
1113
|
+
orWhereNotIn<K extends Extract<keyof TSchema, string> | `${string}.${string}`>(column: K, array: any[]): this;
|
|
1114
1114
|
/**
|
|
1115
1115
|
* @override
|
|
1116
1116
|
* @param {string} column
|
|
1117
1117
|
* @param {string} subQuery
|
|
1118
1118
|
* @return {this}
|
|
1119
1119
|
*/
|
|
1120
|
-
whereSubQuery<K extends Extract<keyof
|
|
1120
|
+
whereSubQuery<K extends Extract<keyof TSchema, string> | `${string}.${string}`>(column: K, subQuery: string): this;
|
|
1121
1121
|
/**
|
|
1122
1122
|
* @override
|
|
1123
1123
|
* @param {string} column
|
|
1124
1124
|
* @param {string} subQuery
|
|
1125
1125
|
* @return {this}
|
|
1126
1126
|
*/
|
|
1127
|
-
whereNotSubQuery<K extends Extract<keyof
|
|
1127
|
+
whereNotSubQuery<K extends Extract<keyof TSchema, string> | `${string}.${string}`>(column: K, subQuery: string): this;
|
|
1128
1128
|
/**
|
|
1129
1129
|
* @override
|
|
1130
1130
|
* @param {string} column
|
|
1131
1131
|
* @param {string} subQuery
|
|
1132
1132
|
* @return {this}
|
|
1133
1133
|
*/
|
|
1134
|
-
orWhereSubQuery<K extends Extract<keyof
|
|
1134
|
+
orWhereSubQuery<K extends Extract<keyof TSchema, string> | `${string}.${string}`>(column: K, subQuery: string): this;
|
|
1135
1135
|
/**
|
|
1136
1136
|
* @override
|
|
1137
1137
|
* @param {string} column
|
|
1138
1138
|
* @param {string} subQuery
|
|
1139
1139
|
* @return {this}
|
|
1140
1140
|
*/
|
|
1141
|
-
orWhereNotSubQuery<K extends Extract<keyof
|
|
1141
|
+
orWhereNotSubQuery<K extends Extract<keyof TSchema, string> | `${string}.${string}`>(column: K, subQuery: string): this;
|
|
1142
1142
|
/**
|
|
1143
1143
|
* @override
|
|
1144
1144
|
* @param {string} column
|
|
1145
1145
|
* @param {array} array
|
|
1146
1146
|
* @return {this}
|
|
1147
1147
|
*/
|
|
1148
|
-
whereBetween<K extends Extract<keyof
|
|
1148
|
+
whereBetween<K extends Extract<keyof TSchema, string> | `${string}.${string}`>(column: K, array: any[]): this;
|
|
1149
1149
|
/**
|
|
1150
1150
|
* @override
|
|
1151
1151
|
* @param {string} column
|
|
1152
1152
|
* @param {array} array
|
|
1153
1153
|
* @return {this}
|
|
1154
1154
|
*/
|
|
1155
|
-
orWhereBetween<K extends Extract<keyof
|
|
1155
|
+
orWhereBetween<K extends Extract<keyof TSchema, string> | `${string}.${string}`>(column: K, array: any[]): this;
|
|
1156
1156
|
/**
|
|
1157
1157
|
* @override
|
|
1158
1158
|
* @param {string} column
|
|
1159
1159
|
* @param {array} array
|
|
1160
1160
|
* @return {this}
|
|
1161
1161
|
*/
|
|
1162
|
-
whereNotBetween<K extends Extract<keyof
|
|
1162
|
+
whereNotBetween<K extends Extract<keyof TSchema, string> | `${string}.${string}`>(column: K, array: any[]): this;
|
|
1163
1163
|
/**
|
|
1164
1164
|
* @override
|
|
1165
1165
|
* @param {string} column
|
|
1166
1166
|
* @param {array} array
|
|
1167
1167
|
* @return {this}
|
|
1168
1168
|
*/
|
|
1169
|
-
orWhereNotBetween<K extends Extract<keyof
|
|
1169
|
+
orWhereNotBetween<K extends Extract<keyof TSchema, string> | `${string}.${string}`>(column: K, array: any[]): this;
|
|
1170
1170
|
/**
|
|
1171
1171
|
* @override
|
|
1172
1172
|
* @param {string} column
|
|
1173
1173
|
* @return {this}
|
|
1174
1174
|
*/
|
|
1175
|
-
whereNull<K extends Extract<keyof
|
|
1175
|
+
whereNull<K extends Extract<keyof TSchema, string> | `${string}.${string}`>(column: K): this;
|
|
1176
1176
|
/**
|
|
1177
1177
|
* @override
|
|
1178
1178
|
* @param {string} column
|
|
1179
1179
|
* @return {this}
|
|
1180
1180
|
*/
|
|
1181
|
-
orWhereNull<K extends Extract<keyof
|
|
1181
|
+
orWhereNull<K extends Extract<keyof TSchema, string> | `${string}.${string}`>(column: K): this;
|
|
1182
1182
|
/**
|
|
1183
1183
|
* @override
|
|
1184
1184
|
* @param {string} column
|
|
1185
1185
|
* @return {this}
|
|
1186
1186
|
*/
|
|
1187
|
-
whereNotNull<K extends Extract<keyof
|
|
1187
|
+
whereNotNull<K extends Extract<keyof TSchema, string> | `${string}.${string}`>(column: K): this;
|
|
1188
1188
|
/**
|
|
1189
1189
|
* @override
|
|
1190
1190
|
* @param {string} column
|
|
1191
1191
|
* @return {this}
|
|
1192
1192
|
*/
|
|
1193
|
-
orWhereNotNull<K extends Extract<keyof
|
|
1193
|
+
orWhereNotNull<K extends Extract<keyof TSchema, string> | `${string}.${string}`>(column: K): this;
|
|
1194
1194
|
/**
|
|
1195
1195
|
* @override
|
|
1196
1196
|
* @param {string} column
|
|
@@ -1198,7 +1198,7 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
|
|
|
1198
1198
|
* @param {any?} value
|
|
1199
1199
|
* @return {this}
|
|
1200
1200
|
*/
|
|
1201
|
-
whereSensitive<K extends Extract<keyof
|
|
1201
|
+
whereSensitive<K extends Extract<keyof TSchema, string> | `${string}.${string}`>(column: K, operator?: any, value?: any): this;
|
|
1202
1202
|
/**
|
|
1203
1203
|
* @override
|
|
1204
1204
|
* @param {string} column
|
|
@@ -1206,7 +1206,7 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
|
|
|
1206
1206
|
* @param {any?} value
|
|
1207
1207
|
* @return {this}
|
|
1208
1208
|
*/
|
|
1209
|
-
whereStrict<K extends Extract<keyof
|
|
1209
|
+
whereStrict<K extends Extract<keyof TSchema, string> | `${string}.${string}`>(column: K, operator?: any, value?: any): this;
|
|
1210
1210
|
/**
|
|
1211
1211
|
* @override
|
|
1212
1212
|
* @param {string} column
|
|
@@ -1214,7 +1214,7 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
|
|
|
1214
1214
|
* @param {any?} value
|
|
1215
1215
|
* @return {this}
|
|
1216
1216
|
*/
|
|
1217
|
-
orWhereSensitive<K extends Extract<keyof
|
|
1217
|
+
orWhereSensitive<K extends Extract<keyof TSchema, string> | `${string}.${string}`>(column: K, operator?: any, value?: any): this;
|
|
1218
1218
|
/**
|
|
1219
1219
|
* @override
|
|
1220
1220
|
* @param {Function} callback callback query
|
|
@@ -1228,7 +1228,7 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
|
|
|
1228
1228
|
* @param {any?} value
|
|
1229
1229
|
* @return {this}
|
|
1230
1230
|
*/
|
|
1231
|
-
whereAny<K extends Extract<keyof
|
|
1231
|
+
whereAny<K extends Extract<keyof TSchema, string> | `${string}.${string}`>(columns: K[], operator?: any, value?: any): this;
|
|
1232
1232
|
/**
|
|
1233
1233
|
* The 'whereAll' method is used to clause to a database query.
|
|
1234
1234
|
*
|
|
@@ -1240,7 +1240,7 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
|
|
|
1240
1240
|
* @param {any?} value
|
|
1241
1241
|
* @return {this}
|
|
1242
1242
|
*/
|
|
1243
|
-
whereAll<K extends Extract<keyof
|
|
1243
|
+
whereAll<K extends Extract<keyof TSchema, string> | `${string}.${string}`>(columns: K[], operator?: any, value?: any): this;
|
|
1244
1244
|
/**
|
|
1245
1245
|
* @override
|
|
1246
1246
|
* @return {promise<boolean>} promise boolean
|
|
@@ -1261,44 +1261,50 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
|
|
|
1261
1261
|
* @return {promise<boolean>}
|
|
1262
1262
|
*/
|
|
1263
1263
|
forceDelete(): Promise<boolean>;
|
|
1264
|
+
/**
|
|
1265
|
+
* @override
|
|
1266
|
+
* @param {string=} column [column=id]
|
|
1267
|
+
* @return {promise<Array>}
|
|
1268
|
+
*/
|
|
1269
|
+
toArray<K extends Extract<keyof TSchema, string> | 'id'>(column?: K): Promise<any[]>;
|
|
1264
1270
|
/**
|
|
1265
1271
|
*
|
|
1266
1272
|
* @override
|
|
1267
1273
|
* @param {Function?} cb callback function return query sql
|
|
1268
1274
|
* @return {promise<Record<string,any> | null>} Record | null
|
|
1269
1275
|
*/
|
|
1270
|
-
first<K>(cb?: Function): Promise<Partial<
|
|
1276
|
+
first<K>(cb?: Function): Promise<Partial<TSchema> & K & TRelation | null>;
|
|
1271
1277
|
/**
|
|
1272
1278
|
* @override
|
|
1273
1279
|
* @param {Function?} cb callback function return query sql
|
|
1274
1280
|
* @return {promise<Record<string,any> | null>} Record | null
|
|
1275
1281
|
*/
|
|
1276
|
-
findOne<K>(cb?: Function): Promise<Partial<
|
|
1282
|
+
findOne<K>(cb?: Function): Promise<Partial<TSchema> & K | null>;
|
|
1277
1283
|
/**
|
|
1278
1284
|
* @override
|
|
1279
1285
|
* @return {promise<object | Error>} Record | throw error
|
|
1280
1286
|
*/
|
|
1281
|
-
firstOrError<K>(message: string, options?: Record<string, any>): Promise<Partial<
|
|
1287
|
+
firstOrError<K>(message: string, options?: Record<string, any>): Promise<Partial<TSchema> & K>;
|
|
1282
1288
|
/**
|
|
1283
1289
|
*
|
|
1284
1290
|
* @override
|
|
1285
1291
|
* @return {promise<any>} Record | throw error
|
|
1286
1292
|
*/
|
|
1287
|
-
findOneOrError<K>(message: string, options?: Record<string, any>): Promise<Partial<
|
|
1293
|
+
findOneOrError<K>(message: string, options?: Record<string, any>): Promise<Partial<TSchema> & K>;
|
|
1288
1294
|
/**
|
|
1289
1295
|
*
|
|
1290
1296
|
* @override
|
|
1291
1297
|
* @param {Function?} cb callback function return query sql
|
|
1292
1298
|
* @return {promise<array>} Array
|
|
1293
1299
|
*/
|
|
1294
|
-
get<K = Partial<
|
|
1300
|
+
get<K = Partial<TSchema>>(cb?: Function): Promise<Partial<TSchema[]> & K[]>;
|
|
1295
1301
|
/**
|
|
1296
1302
|
*
|
|
1297
1303
|
* @override
|
|
1298
1304
|
* @param {Function?} cb callback function return query sql
|
|
1299
1305
|
* @return {promise<array>} Array
|
|
1300
1306
|
*/
|
|
1301
|
-
findMany<K = Partial<
|
|
1307
|
+
findMany<K = Partial<TSchema>>(cb?: Function): Promise<Partial<TSchema[]> & K[]>;
|
|
1302
1308
|
/**
|
|
1303
1309
|
* @override
|
|
1304
1310
|
* @param {object?} paginationOptions by default page = 1 , limit = 15
|
|
@@ -1333,7 +1339,7 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
|
|
|
1333
1339
|
* @param {object} data for insert
|
|
1334
1340
|
* @return {this} this
|
|
1335
1341
|
*/
|
|
1336
|
-
insert<K extends keyof
|
|
1342
|
+
insert<K extends keyof TSchema>(data: K extends keyof TSchema ? {
|
|
1337
1343
|
[P in K]: string | number | boolean | null | undefined;
|
|
1338
1344
|
} : never): this;
|
|
1339
1345
|
/**
|
|
@@ -1341,7 +1347,7 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
|
|
|
1341
1347
|
* @param {object} data for insert
|
|
1342
1348
|
* @return {this} this
|
|
1343
1349
|
*/
|
|
1344
|
-
create<K extends keyof
|
|
1350
|
+
create<K extends keyof TSchema>(data: K extends keyof TSchema ? {
|
|
1345
1351
|
[P in K]: string | number | boolean | null | undefined;
|
|
1346
1352
|
} : never): this;
|
|
1347
1353
|
/**
|
|
@@ -1350,7 +1356,7 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
|
|
|
1350
1356
|
* @param {array?} updateNotExists options for except update some records in your ${data}
|
|
1351
1357
|
* @return {this} this
|
|
1352
1358
|
*/
|
|
1353
|
-
update<K extends keyof
|
|
1359
|
+
update<K extends keyof TSchema>(data: K extends keyof TSchema ? {
|
|
1354
1360
|
[P in K]: string | number | boolean | null | undefined;
|
|
1355
1361
|
} : never, updateNotExists?: string[]): this;
|
|
1356
1362
|
/**
|
|
@@ -1359,7 +1365,7 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
|
|
|
1359
1365
|
* @param {array?} updateNotExists options for except update some records in your ${data}
|
|
1360
1366
|
* @return {this} this
|
|
1361
1367
|
*/
|
|
1362
|
-
updateMany<K extends keyof
|
|
1368
|
+
updateMany<K extends keyof TSchema>(data: K extends keyof TSchema ? {
|
|
1363
1369
|
[P in K]: string | number | boolean | null | undefined;
|
|
1364
1370
|
} : never, updateNotExists?: string[]): this;
|
|
1365
1371
|
/**
|
|
@@ -1367,7 +1373,7 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
|
|
|
1367
1373
|
* @param {object} data
|
|
1368
1374
|
* @return {this} this
|
|
1369
1375
|
*/
|
|
1370
|
-
updateNotExists<K extends keyof
|
|
1376
|
+
updateNotExists<K extends keyof TSchema>(data: K extends keyof TSchema ? {
|
|
1371
1377
|
[P in K]: string | number | boolean | null | undefined;
|
|
1372
1378
|
} : never): this;
|
|
1373
1379
|
/**
|
|
@@ -1375,7 +1381,7 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
|
|
|
1375
1381
|
* @param {object} data for update or create
|
|
1376
1382
|
* @return {this} this
|
|
1377
1383
|
*/
|
|
1378
|
-
updateOrCreate<K extends keyof
|
|
1384
|
+
updateOrCreate<K extends keyof TSchema>(data: K extends keyof TSchema ? {
|
|
1379
1385
|
[P in K]: string | number | boolean | null | undefined;
|
|
1380
1386
|
} : never): this;
|
|
1381
1387
|
/**
|
|
@@ -1383,7 +1389,7 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
|
|
|
1383
1389
|
* @param {object} data for update or create
|
|
1384
1390
|
* @return {this} this
|
|
1385
1391
|
*/
|
|
1386
|
-
updateOrInsert<K extends keyof
|
|
1392
|
+
updateOrInsert<K extends keyof TSchema>(data: K extends keyof TSchema ? {
|
|
1387
1393
|
[P in K]: string | number | boolean | null | undefined;
|
|
1388
1394
|
} : never): this;
|
|
1389
1395
|
/**
|
|
@@ -1391,7 +1397,7 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
|
|
|
1391
1397
|
* @param {object} data for update or create
|
|
1392
1398
|
* @return {this} this
|
|
1393
1399
|
*/
|
|
1394
|
-
insertOrUpdate<K extends keyof
|
|
1400
|
+
insertOrUpdate<K extends keyof TSchema>(data: K extends keyof TSchema ? {
|
|
1395
1401
|
[P in K]: string | number | boolean | null | undefined;
|
|
1396
1402
|
} : never): this;
|
|
1397
1403
|
/**
|
|
@@ -1399,7 +1405,7 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
|
|
|
1399
1405
|
* @param {object} data for update or create
|
|
1400
1406
|
* @return {this} this
|
|
1401
1407
|
*/
|
|
1402
|
-
createOrUpdate<K extends keyof
|
|
1408
|
+
createOrUpdate<K extends keyof TSchema>(data: K extends keyof TSchema ? {
|
|
1403
1409
|
[P in K]: string | number | boolean | null | undefined;
|
|
1404
1410
|
} : never): this;
|
|
1405
1411
|
/**
|
|
@@ -1407,7 +1413,7 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
|
|
|
1407
1413
|
* @param {object} data for create
|
|
1408
1414
|
* @return {this} this
|
|
1409
1415
|
*/
|
|
1410
|
-
createOrSelect<K extends keyof
|
|
1416
|
+
createOrSelect<K extends keyof TSchema>(data: K extends keyof TSchema ? {
|
|
1411
1417
|
[P in K]: string | number | boolean | null | undefined;
|
|
1412
1418
|
} : never): this;
|
|
1413
1419
|
/**
|
|
@@ -1415,7 +1421,7 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
|
|
|
1415
1421
|
* @param {object} data for update or create
|
|
1416
1422
|
* @return {this} this
|
|
1417
1423
|
*/
|
|
1418
|
-
insertOrSelect<K extends keyof
|
|
1424
|
+
insertOrSelect<K extends keyof TSchema>(data: K extends keyof TSchema ? {
|
|
1419
1425
|
[P in K]: string | number | boolean | null | undefined;
|
|
1420
1426
|
} : never): this;
|
|
1421
1427
|
/**
|
|
@@ -1423,21 +1429,21 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
|
|
|
1423
1429
|
* @param {Record<string,any>[]} data create multiple data
|
|
1424
1430
|
* @return {this} this this
|
|
1425
1431
|
*/
|
|
1426
|
-
createMultiple<K extends keyof
|
|
1432
|
+
createMultiple<K extends keyof TSchema>(data: Record<K, string | number | boolean | null | undefined>[]): this;
|
|
1427
1433
|
/**
|
|
1428
1434
|
*
|
|
1429
1435
|
* @override
|
|
1430
1436
|
* @param {Record<string,any>[]} data create multiple data
|
|
1431
1437
|
* @return {this} this
|
|
1432
1438
|
*/
|
|
1433
|
-
insertMultiple<K extends keyof
|
|
1439
|
+
insertMultiple<K extends keyof TSchema>(data: Record<K, string | number | boolean | null | undefined>[]): this;
|
|
1434
1440
|
/**
|
|
1435
1441
|
*
|
|
1436
1442
|
* @override
|
|
1437
1443
|
* @param {object} data create not exists data
|
|
1438
1444
|
* @return {this} this
|
|
1439
1445
|
*/
|
|
1440
|
-
createNotExists<K extends keyof
|
|
1446
|
+
createNotExists<K extends keyof TSchema>(data: K extends keyof TSchema ? {
|
|
1441
1447
|
[P in K]: string | number | boolean | null | undefined;
|
|
1442
1448
|
} : never): this;
|
|
1443
1449
|
/**
|
|
@@ -1446,7 +1452,7 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
|
|
|
1446
1452
|
* @param {object} data create not exists data
|
|
1447
1453
|
* @return {this} this this
|
|
1448
1454
|
*/
|
|
1449
|
-
insertNotExists<K extends keyof
|
|
1455
|
+
insertNotExists<K extends keyof TSchema>(data: K extends keyof TSchema ? {
|
|
1450
1456
|
[P in K]: string | number | boolean | null | undefined;
|
|
1451
1457
|
} : never): this;
|
|
1452
1458
|
/**
|
|
@@ -1481,7 +1487,7 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
|
|
|
1481
1487
|
* @param {Function} callback function will be called data and index
|
|
1482
1488
|
* @return {promise<any[]>}
|
|
1483
1489
|
*/
|
|
1484
|
-
faker(rows: number, callback?: Function): Promise<
|
|
1490
|
+
faker(rows: number, callback?: Function): Promise<void>;
|
|
1485
1491
|
/**
|
|
1486
1492
|
* The 'Sync' method is used to check for create or update table or columns with your schema in your model.
|
|
1487
1493
|
* @type {object} options
|