tspace-mysql 1.5.2 → 1.5.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.
@@ -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<TSchemaModel extends Record<string, Blueprint | string | number | Date> = any, TRelationModel = any> extends AbstractModel<TSchemaModel, TRelationModel> {
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 TSchemaModel>(column: K): K;
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 TRelationModel>(name: K, callback?: Function): this;
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 TSchemaModel, string> | `${string}.${string}` | '*'>(...columns: K[]): this;
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 TSchemaModel, string> | `${string}.${string}`>(...columns: K[]): this;
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 TSchemaModel, string> | `${string}.${string}`>(column: K, order?: 'ASC' | 'DESC'): this;
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 TSchemaModel, string> | `${string}.${string}`>(...columns: K[]): this;
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 TSchemaModel, string> | `${string}.${string}`>(...columns: K[]): this;
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 TSchemaModel, string> | `${string}.${string}`>(...columns: K[]): this;
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 TRelationModel>(...nameRelations: K[]): this;
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 TRelationModel>(...nameRelations: K[]): this;
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 TRelationModel>(...nameRelations: K[]): this;
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 TRelationModel>(...nameRelations: K[]): this;
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 TRelationModel>(...nameRelations: K[]): this;
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 TRelationModel>(...nameRelations: K[]): this;
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 TRelationModel, TModel extends Model>(nameRelation: K, callback: (query: TModel) => TModel): this;
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 TRelationModel>(...nameRelations: K[]): this;
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 TRelationModel, T extends Model>(nameRelation: K, callback: (query: T) => T): this;
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 TRelationModel>(...nameRelations: K[]): this;
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 TRelationModel>(...nameRelations: K[]): this;
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 TRelationModel>({ name, as, model, localKey, foreignKey, freezeTable }: Relation<K>): this;
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 TRelationModel>({ name, as, model, localKey, foreignKey, freezeTable }: Relation<K>): this;
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 TRelationModel>({ name, as, model, localKey, foreignKey, freezeTable }: Relation<K>): this;
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 TRelationModel>({ name, as, model, localKey, foreignKey, freezeTable, pivot, oldVersion, modelPivot }: Relation<K>): this;
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 TSchemaModel, string> | `${string}.${string}`>(column: K | Record<string, any>, operator?: any, value?: any): this;
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 TSchemaModel, string> | `${string}.${string}`>(column: K, operator?: any, value?: any): this;
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<string, any>): this;
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 TSchemaModel, string> | `${string}.${string}`>(column: K, { key, value, operator }: {
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 TSchemaModel, string> | `${string}.${string}`>(column: K, array: any[]): this;
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 TSchemaModel, string> | `${string}.${string}`>(column: K, array: any[]): this;
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 TSchemaModel, string> | `${string}.${string}`>(column: K, array: any[]): this;
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 TSchemaModel, string> | `${string}.${string}`>(column: K, array: any[]): this;
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 TSchemaModel, string> | `${string}.${string}`>(column: K, subQuery: string): this;
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 TSchemaModel, string> | `${string}.${string}`>(column: K, subQuery: string): this;
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 TSchemaModel, string> | `${string}.${string}`>(column: K, subQuery: string): this;
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 TSchemaModel, string> | `${string}.${string}`>(column: K, subQuery: string): this;
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 TSchemaModel, string> | `${string}.${string}`>(column: K, array: any[]): this;
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 TSchemaModel, string> | `${string}.${string}`>(column: K, array: any[]): this;
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 TSchemaModel, string> | `${string}.${string}`>(column: K, array: any[]): this;
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 TSchemaModel, string> | `${string}.${string}`>(column: K, array: any[]): this;
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 TSchemaModel, string> | `${string}.${string}`>(column: K): this;
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 TSchemaModel, string> | `${string}.${string}`>(column: K): this;
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 TSchemaModel, string> | `${string}.${string}`>(column: K): this;
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 TSchemaModel, string> | `${string}.${string}`>(column: K): this;
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 TSchemaModel, string> | `${string}.${string}`>(column: K, operator?: any, value?: any): this;
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 TSchemaModel, string> | `${string}.${string}`>(column: K, operator?: any, value?: any): this;
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 TSchemaModel, string> | `${string}.${string}`>(column: K, operator?: any, value?: any): this;
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 TSchemaModel, string> | `${string}.${string}`>(columns: K[], operator?: any, value?: any): this;
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 TSchemaModel, string> | `${string}.${string}`>(columns: K[], operator?: any, value?: any): this;
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<TSchemaModel> & K & TRelationModel | null>;
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<TSchemaModel> & K | null>;
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<TSchemaModel> & K>;
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<TSchemaModel> & K>;
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<TSchemaModel>>(cb?: Function): Promise<Partial<TSchemaModel[]> & K[]>;
1300
+ get<K>(cb?: Function): Promise<Partial<(TSchema & TRelation & 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<TSchemaModel>>(cb?: Function): Promise<Partial<TSchemaModel[]> & K[]>;
1307
+ findMany<K>(cb?: Function): Promise<Partial<(TSchema & TRelation & K)>[]>;
1302
1308
  /**
1303
1309
  * @override
1304
1310
  * @param {object?} paginationOptions by default page = 1 , limit = 15
@@ -1306,10 +1312,10 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
1306
1312
  * @property {number} paginationOptions.page
1307
1313
  * @return {promise<Pagination>} Pagination
1308
1314
  */
1309
- pagination(paginationOptions?: {
1315
+ pagination<K>(paginationOptions?: {
1310
1316
  limit?: number;
1311
1317
  page?: number;
1312
- }): Promise<Pagination>;
1318
+ }): Promise<Pagination<Partial<(TSchema & TRelation & K)>[]>>;
1313
1319
  /**
1314
1320
  *
1315
1321
  * @override
@@ -1318,22 +1324,28 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
1318
1324
  * @property {number} paginationOptions.page
1319
1325
  * @return {promise<Pagination>} Pagination
1320
1326
  */
1321
- paginate(paginationOptions?: {
1327
+ paginate<K>(paginationOptions?: {
1322
1328
  limit?: number;
1323
1329
  page?: number;
1324
- }): Promise<Pagination>;
1330
+ }): Promise<Pagination<Partial<(TSchema & TRelation & K)>[]>>;
1325
1331
  /**
1326
1332
  * @override
1327
1333
  * @param {string} column
1328
1334
  * @return {Promise<array>} Array
1329
1335
  */
1330
- getGroupBy(column: string): Promise<any[]>;
1336
+ getGroupBy<K extends Extract<keyof TSchema, string> | `${string}.${string}`>(column: K): Promise<any[]>;
1337
+ /**
1338
+ * @override
1339
+ * @param {string} column
1340
+ * @return {Promise<array>} Array
1341
+ */
1342
+ findGroupBy<K extends Extract<keyof TSchema, string> | `${string}.${string}`>(column: K): Promise<any[]>;
1331
1343
  /**
1332
1344
  * @override
1333
1345
  * @param {object} data for insert
1334
1346
  * @return {this} this
1335
1347
  */
1336
- insert<K extends keyof TSchemaModel>(data: K extends keyof TSchemaModel ? {
1348
+ insert<K extends keyof TSchema>(data: K extends keyof TSchema ? {
1337
1349
  [P in K]: string | number | boolean | null | undefined;
1338
1350
  } : never): this;
1339
1351
  /**
@@ -1341,7 +1353,7 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
1341
1353
  * @param {object} data for insert
1342
1354
  * @return {this} this
1343
1355
  */
1344
- create<K extends keyof TSchemaModel>(data: K extends keyof TSchemaModel ? {
1356
+ create<K extends keyof TSchema>(data: K extends keyof TSchema ? {
1345
1357
  [P in K]: string | number | boolean | null | undefined;
1346
1358
  } : never): this;
1347
1359
  /**
@@ -1350,7 +1362,7 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
1350
1362
  * @param {array?} updateNotExists options for except update some records in your ${data}
1351
1363
  * @return {this} this
1352
1364
  */
1353
- update<K extends keyof TSchemaModel>(data: K extends keyof TSchemaModel ? {
1365
+ update<K extends keyof TSchema>(data: K extends keyof TSchema ? {
1354
1366
  [P in K]: string | number | boolean | null | undefined;
1355
1367
  } : never, updateNotExists?: string[]): this;
1356
1368
  /**
@@ -1359,7 +1371,7 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
1359
1371
  * @param {array?} updateNotExists options for except update some records in your ${data}
1360
1372
  * @return {this} this
1361
1373
  */
1362
- updateMany<K extends keyof TSchemaModel>(data: K extends keyof TSchemaModel ? {
1374
+ updateMany<K extends keyof TSchema>(data: K extends keyof TSchema ? {
1363
1375
  [P in K]: string | number | boolean | null | undefined;
1364
1376
  } : never, updateNotExists?: string[]): this;
1365
1377
  /**
@@ -1367,7 +1379,7 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
1367
1379
  * @param {object} data
1368
1380
  * @return {this} this
1369
1381
  */
1370
- updateNotExists<K extends keyof TSchemaModel>(data: K extends keyof TSchemaModel ? {
1382
+ updateNotExists<K extends keyof TSchema>(data: K extends keyof TSchema ? {
1371
1383
  [P in K]: string | number | boolean | null | undefined;
1372
1384
  } : never): this;
1373
1385
  /**
@@ -1375,7 +1387,7 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
1375
1387
  * @param {object} data for update or create
1376
1388
  * @return {this} this
1377
1389
  */
1378
- updateOrCreate<K extends keyof TSchemaModel>(data: K extends keyof TSchemaModel ? {
1390
+ updateOrCreate<K extends keyof TSchema>(data: K extends keyof TSchema ? {
1379
1391
  [P in K]: string | number | boolean | null | undefined;
1380
1392
  } : never): this;
1381
1393
  /**
@@ -1383,7 +1395,7 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
1383
1395
  * @param {object} data for update or create
1384
1396
  * @return {this} this
1385
1397
  */
1386
- updateOrInsert<K extends keyof TSchemaModel>(data: K extends keyof TSchemaModel ? {
1398
+ updateOrInsert<K extends keyof TSchema>(data: K extends keyof TSchema ? {
1387
1399
  [P in K]: string | number | boolean | null | undefined;
1388
1400
  } : never): this;
1389
1401
  /**
@@ -1391,7 +1403,7 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
1391
1403
  * @param {object} data for update or create
1392
1404
  * @return {this} this
1393
1405
  */
1394
- insertOrUpdate<K extends keyof TSchemaModel>(data: K extends keyof TSchemaModel ? {
1406
+ insertOrUpdate<K extends keyof TSchema>(data: K extends keyof TSchema ? {
1395
1407
  [P in K]: string | number | boolean | null | undefined;
1396
1408
  } : never): this;
1397
1409
  /**
@@ -1399,7 +1411,7 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
1399
1411
  * @param {object} data for update or create
1400
1412
  * @return {this} this
1401
1413
  */
1402
- createOrUpdate<K extends keyof TSchemaModel>(data: K extends keyof TSchemaModel ? {
1414
+ createOrUpdate<K extends keyof TSchema>(data: K extends keyof TSchema ? {
1403
1415
  [P in K]: string | number | boolean | null | undefined;
1404
1416
  } : never): this;
1405
1417
  /**
@@ -1407,7 +1419,7 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
1407
1419
  * @param {object} data for create
1408
1420
  * @return {this} this
1409
1421
  */
1410
- createOrSelect<K extends keyof TSchemaModel>(data: K extends keyof TSchemaModel ? {
1422
+ createOrSelect<K extends keyof TSchema>(data: K extends keyof TSchema ? {
1411
1423
  [P in K]: string | number | boolean | null | undefined;
1412
1424
  } : never): this;
1413
1425
  /**
@@ -1415,7 +1427,7 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
1415
1427
  * @param {object} data for update or create
1416
1428
  * @return {this} this
1417
1429
  */
1418
- insertOrSelect<K extends keyof TSchemaModel>(data: K extends keyof TSchemaModel ? {
1430
+ insertOrSelect<K extends keyof TSchema>(data: K extends keyof TSchema ? {
1419
1431
  [P in K]: string | number | boolean | null | undefined;
1420
1432
  } : never): this;
1421
1433
  /**
@@ -1423,21 +1435,21 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
1423
1435
  * @param {Record<string,any>[]} data create multiple data
1424
1436
  * @return {this} this this
1425
1437
  */
1426
- createMultiple<K extends keyof TSchemaModel>(data: Record<K, string | number | boolean | null | undefined>[]): this;
1438
+ createMultiple<K extends keyof TSchema>(data: Record<K, string | number | boolean | null | undefined>[]): this;
1427
1439
  /**
1428
1440
  *
1429
1441
  * @override
1430
1442
  * @param {Record<string,any>[]} data create multiple data
1431
1443
  * @return {this} this
1432
1444
  */
1433
- insertMultiple<K extends keyof TSchemaModel>(data: Record<K, string | number | boolean | null | undefined>[]): this;
1445
+ insertMultiple<K extends keyof TSchema>(data: Record<K, string | number | boolean | null | undefined>[]): this;
1434
1446
  /**
1435
1447
  *
1436
1448
  * @override
1437
1449
  * @param {object} data create not exists data
1438
1450
  * @return {this} this
1439
1451
  */
1440
- createNotExists<K extends keyof TSchemaModel>(data: K extends keyof TSchemaModel ? {
1452
+ createNotExists<K extends keyof TSchema>(data: K extends keyof TSchema ? {
1441
1453
  [P in K]: string | number | boolean | null | undefined;
1442
1454
  } : never): this;
1443
1455
  /**
@@ -1446,7 +1458,7 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
1446
1458
  * @param {object} data create not exists data
1447
1459
  * @return {this} this this
1448
1460
  */
1449
- insertNotExists<K extends keyof TSchemaModel>(data: K extends keyof TSchemaModel ? {
1461
+ insertNotExists<K extends keyof TSchema>(data: K extends keyof TSchema ? {
1450
1462
  [P in K]: string | number | boolean | null | undefined;
1451
1463
  } : never): this;
1452
1464
  /**
@@ -1461,7 +1473,16 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
1461
1473
  when: Record<string, any>;
1462
1474
  columns: Record<string, string | number | boolean | null | undefined>;
1463
1475
  }[]): this;
1476
+ /**
1477
+ * The 'getSchemaModel' method is used get a schema model
1478
+ * @return {Record<string, Blueprint> | null} Record<string, Blueprint> | null
1479
+ */
1464
1480
  getSchemaModel(): Record<string, Blueprint> | null;
1481
+ /**
1482
+ * The 'validation' method is used validate the column by validating
1483
+ * @param {ValidateSchema} schema
1484
+ * @return {this} this
1485
+ */
1465
1486
  validation(schema?: ValidateSchema): this;
1466
1487
  /**
1467
1488
  * The 'bindPattern' method is used to covert column relate with pattern
@@ -1481,7 +1502,7 @@ declare class Model<TSchemaModel extends Record<string, Blueprint | string | num
1481
1502
  * @param {Function} callback function will be called data and index
1482
1503
  * @return {promise<any[]>}
1483
1504
  */
1484
- faker(rows: number, callback?: Function): Promise<Record<string, any>[]>;
1505
+ faker(rows: number, callback?: Function): Promise<void>;
1485
1506
  /**
1486
1507
  * The 'Sync' method is used to check for create or update table or columns with your schema in your model.
1487
1508
  * @type {object} options