imodel 0.12.0 → 0.13.0
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/index.d.mts +57 -62
- package/index.mjs +66 -66
- package/migrate.d.mts +1 -1
- package/migrate.mjs +1 -1
- package/package.json +1 -1
package/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* imodel v0.
|
|
2
|
+
* imodel v0.13.0
|
|
3
3
|
* (c) 2019-2026 undefined
|
|
4
4
|
* @license undefined
|
|
5
5
|
*/
|
|
@@ -659,18 +659,13 @@ interface FieldDefineOption {
|
|
|
659
659
|
text?: boolean;
|
|
660
660
|
/** 排序顺序,绝对值表示在排序列表中的顺序,负数表示逆序排序, 0 表示不排序 */
|
|
661
661
|
sort?: number;
|
|
662
|
+
constraints?: Record<string, Constraint>;
|
|
662
663
|
}
|
|
663
664
|
/** 字段类型信息 */
|
|
664
665
|
interface FieldDefine<T extends MainFieldType = MainFieldType, A extends boolean = boolean, N extends boolean = boolean> extends FieldTypeDefine<T, A, N>, FieldDefineOption {
|
|
665
666
|
/** 默认值 */
|
|
666
667
|
default?: ToType<T, A, N>;
|
|
667
668
|
}
|
|
668
|
-
/** 字段类型信息 */
|
|
669
|
-
interface FieldDefine<T extends MainFieldType = MainFieldType, A extends boolean = boolean, N extends boolean = boolean> extends FieldTypeDefine<T, A, N>, FieldDefineOption {
|
|
670
|
-
/** 默认值 */
|
|
671
|
-
default?: ToType<T, A, N>;
|
|
672
|
-
constraints?: Record<string, Constraint>;
|
|
673
|
-
}
|
|
674
669
|
interface FieldTypeDefine<T extends MainFieldType = MainFieldType, A extends boolean = boolean, N extends boolean = boolean> {
|
|
675
670
|
/** 字段的基本类型 */
|
|
676
671
|
type: T;
|
|
@@ -697,15 +692,15 @@ interface Index extends IndexInfo {
|
|
|
697
692
|
name: string;
|
|
698
693
|
}
|
|
699
694
|
interface Hooks<T extends Record<string, any> = Record<string, any>> {
|
|
700
|
-
where(conn: Connection): PromiseLike<void | Where> | void;
|
|
701
|
-
beforeCreateMany(conn: Connection, records: Record<string, any>[]): PromiseLike<void | Record<string, any>[]> | void | Record<string, any>[];
|
|
702
|
-
afterCreateMany(conn: Connection, records: Record<string, any>[]): PromiseLike<void> | void;
|
|
703
|
-
beforeCreate(conn: Connection, record: Record<string, any>): PromiseLike<void | Record<string, any>> | void | Record<string, any>;
|
|
704
|
-
afterCreate(conn: Connection, record: Record<string, any>): PromiseLike<void> | void;
|
|
705
|
-
beforeUpdate(conn: Connection, record: Record<string, any>, set: Record<string, any>): PromiseLike<void | Record<string, any>> | void | Record<string, any>;
|
|
706
|
-
afterUpdate(conn: Connection, record: Record<string, any>, oldRecord: Record<string, any>): PromiseLike<void> | void;
|
|
707
|
-
beforeDelete(conn: Connection, record: T, update: Record<string, any> | null): PromiseLike<void> | void;
|
|
708
|
-
afterDelete(conn: Connection, record: T, update: Record<string, any> | null): PromiseLike<void> | void;
|
|
695
|
+
where(conn: Connection, model: TableDefine): PromiseLike<void | Where> | void;
|
|
696
|
+
beforeCreateMany(conn: Connection, model: TableDefine, records: Record<string, any>[]): PromiseLike<void | Record<string, any>[]> | void | Record<string, any>[];
|
|
697
|
+
afterCreateMany(conn: Connection, model: TableDefine, records: Record<string, any>[]): PromiseLike<void> | void;
|
|
698
|
+
beforeCreate(conn: Connection, model: TableDefine, record: Record<string, any>): PromiseLike<void | Record<string, any>> | void | Record<string, any>;
|
|
699
|
+
afterCreate(conn: Connection, model: TableDefine, record: Record<string, any>): PromiseLike<void> | void;
|
|
700
|
+
beforeUpdate(conn: Connection, model: TableDefine, record: Record<string, any>, set: Record<string, any>): PromiseLike<void | Record<string, any>> | void | Record<string, any>;
|
|
701
|
+
afterUpdate(conn: Connection, model: TableDefine, record: Record<string, any>, oldRecord: Record<string, any>): PromiseLike<void> | void;
|
|
702
|
+
beforeDelete(conn: Connection, model: TableDefine, record: T, update: Record<string, any> | null): PromiseLike<void> | void;
|
|
703
|
+
afterDelete(conn: Connection, model: TableDefine, record: T, update: Record<string, any> | null): PromiseLike<void> | void;
|
|
709
704
|
}
|
|
710
705
|
interface TableDefine<T extends Fields = Fields, TT extends string | VirtualTable | undefined = string | VirtualTable | undefined> {
|
|
711
706
|
/** 字段信息 */
|
|
@@ -865,7 +860,7 @@ interface TransactionFn {
|
|
|
865
860
|
* @param {{
|
|
866
861
|
* nullable?: false;
|
|
867
862
|
* array?: false;
|
|
868
|
-
* default?: ToType<T, false, false
|
|
863
|
+
* default?: ToType<T, false, false> | symbol;
|
|
869
864
|
* [k: string]: any;
|
|
870
865
|
* } & FieldDefineOption} [options]
|
|
871
866
|
* @returns {FieldDecorator<ToType<T, false, false>>}
|
|
@@ -874,7 +869,7 @@ declare function field$1<T extends keyof FieldType>(type: T, options?: ({
|
|
|
874
869
|
[k: string]: any;
|
|
875
870
|
nullable?: false;
|
|
876
871
|
array?: false;
|
|
877
|
-
default?: ToType<T, false, false
|
|
872
|
+
default?: ToType<T, false, false> | symbol;
|
|
878
873
|
} & FieldDefineOption) | undefined): FieldDecorator<ToType<T, false, false>>;
|
|
879
874
|
/**
|
|
880
875
|
* @template {keyof FieldType} T
|
|
@@ -883,7 +878,7 @@ declare function field$1<T extends keyof FieldType>(type: T, options?: ({
|
|
|
883
878
|
* @param {{
|
|
884
879
|
* nullable?: false;
|
|
885
880
|
* array: true;
|
|
886
|
-
* default?: ToType<T, true, false
|
|
881
|
+
* default?: ToType<T, true, false> | symbol;
|
|
887
882
|
* [k: string]: any;
|
|
888
883
|
* } & FieldDefineOption} options
|
|
889
884
|
* @returns {FieldDecorator<ToType<T, true, false>>}
|
|
@@ -891,7 +886,7 @@ declare function field$1<T extends keyof FieldType>(type: T, options?: ({
|
|
|
891
886
|
declare function field$1<T extends keyof FieldType>(type: T, options: {
|
|
892
887
|
nullable?: false;
|
|
893
888
|
array: true;
|
|
894
|
-
default?: ToType<T, true, false
|
|
889
|
+
default?: ToType<T, true, false> | symbol;
|
|
895
890
|
[k: string]: any;
|
|
896
891
|
} & FieldDefineOption): FieldDecorator<ToType<T, true, false>>;
|
|
897
892
|
/**
|
|
@@ -901,14 +896,14 @@ declare function field$1<T extends keyof FieldType>(type: T, options: {
|
|
|
901
896
|
* @param {true} array
|
|
902
897
|
* @param {{
|
|
903
898
|
* nullable?: false;
|
|
904
|
-
* default?: ToType<T, true, false
|
|
899
|
+
* default?: ToType<T, true, false> | symbol;
|
|
905
900
|
* [k: string]: any;
|
|
906
901
|
* } & FieldDefineOption} options
|
|
907
902
|
* @returns {FieldDecorator<ToType<T, true, false>>}
|
|
908
903
|
*/
|
|
909
904
|
declare function field$1<T extends keyof FieldType>(type: T, array: true, options: {
|
|
910
905
|
nullable?: false;
|
|
911
|
-
default?: ToType<T, true, false
|
|
906
|
+
default?: ToType<T, true, false> | symbol;
|
|
912
907
|
[k: string]: any;
|
|
913
908
|
} & FieldDefineOption): FieldDecorator<ToType<T, true, false>>;
|
|
914
909
|
/**
|
|
@@ -918,7 +913,7 @@ declare function field$1<T extends keyof FieldType>(type: T, array: true, option
|
|
|
918
913
|
* @param {{
|
|
919
914
|
* nullable: true;
|
|
920
915
|
* array?: false;
|
|
921
|
-
* default?: ToType<T, false, true
|
|
916
|
+
* default?: ToType<T, false, true> | symbol;
|
|
922
917
|
* [k: string]: any;
|
|
923
918
|
* } & FieldDefineOption} options
|
|
924
919
|
* @returns {FieldDecorator<ToType<T, false, true>>}
|
|
@@ -926,7 +921,7 @@ declare function field$1<T extends keyof FieldType>(type: T, array: true, option
|
|
|
926
921
|
declare function field$1<T extends keyof FieldType>(type: T, options: {
|
|
927
922
|
nullable: true;
|
|
928
923
|
array?: false;
|
|
929
|
-
default?: ToType<T, false, true
|
|
924
|
+
default?: ToType<T, false, true> | symbol;
|
|
930
925
|
[k: string]: any;
|
|
931
926
|
} & FieldDefineOption): FieldDecorator<ToType<T, false, true>>;
|
|
932
927
|
/**
|
|
@@ -936,7 +931,7 @@ declare function field$1<T extends keyof FieldType>(type: T, options: {
|
|
|
936
931
|
* @param {{
|
|
937
932
|
* nullable: true;
|
|
938
933
|
* array: true;
|
|
939
|
-
* default?: ToType<T, true, true
|
|
934
|
+
* default?: ToType<T, true, true> | symbol;
|
|
940
935
|
* [k: string]: any;
|
|
941
936
|
* } & FieldDefineOption} options
|
|
942
937
|
* @returns {FieldDecorator<ToType<T, true, true>>}
|
|
@@ -944,7 +939,7 @@ declare function field$1<T extends keyof FieldType>(type: T, options: {
|
|
|
944
939
|
declare function field$1<T extends keyof FieldType>(type: T, options: {
|
|
945
940
|
nullable: true;
|
|
946
941
|
array: true;
|
|
947
|
-
default?: ToType<T, true, true
|
|
942
|
+
default?: ToType<T, true, true> | symbol;
|
|
948
943
|
[k: string]: any;
|
|
949
944
|
} & FieldDefineOption): FieldDecorator<ToType<T, true, true>>;
|
|
950
945
|
/**
|
|
@@ -954,14 +949,14 @@ declare function field$1<T extends keyof FieldType>(type: T, options: {
|
|
|
954
949
|
* @param {true} array
|
|
955
950
|
* @param {{
|
|
956
951
|
* nullable: true;
|
|
957
|
-
* default?: ToType<T, true, true
|
|
952
|
+
* default?: ToType<T, true, true> | symbol;
|
|
958
953
|
* [k: string]: any;
|
|
959
954
|
* } & FieldDefineOption} options
|
|
960
955
|
* @returns {FieldDecorator<ToType<T, true, true>>}
|
|
961
956
|
*/
|
|
962
957
|
declare function field$1<T extends keyof FieldType>(type: T, array: true, options: {
|
|
963
958
|
nullable: true;
|
|
964
|
-
default?: ToType<T, true, true
|
|
959
|
+
default?: ToType<T, true, true> | symbol;
|
|
965
960
|
[k: string]: any;
|
|
966
961
|
} & FieldDefineOption): FieldDecorator<ToType<T, true, true>>;
|
|
967
962
|
/**
|
|
@@ -972,7 +967,7 @@ declare function field$1<T extends keyof FieldType>(type: T, array: true, option
|
|
|
972
967
|
* @param {{
|
|
973
968
|
* nullable: true;
|
|
974
969
|
* array: A;
|
|
975
|
-
* default?: ToType<T, A, true
|
|
970
|
+
* default?: ToType<T, A, true> | symbol;
|
|
976
971
|
* [k: string]: any;
|
|
977
972
|
* } & FieldDefineOption} options
|
|
978
973
|
* @returns {FieldDecorator<ToType<T, A, true>>}
|
|
@@ -980,7 +975,7 @@ declare function field$1<T extends keyof FieldType>(type: T, array: true, option
|
|
|
980
975
|
declare function field$1<T extends keyof FieldType, A extends boolean>(type: T, options: {
|
|
981
976
|
nullable: true;
|
|
982
977
|
array: A;
|
|
983
|
-
default?: ToType<T, A, true
|
|
978
|
+
default?: ToType<T, A, true> | symbol;
|
|
984
979
|
[k: string]: any;
|
|
985
980
|
} & FieldDefineOption): FieldDecorator<ToType<T, A, true>>;
|
|
986
981
|
/**
|
|
@@ -991,7 +986,7 @@ declare function field$1<T extends keyof FieldType, A extends boolean>(type: T,
|
|
|
991
986
|
* @param {{
|
|
992
987
|
* nullable?: false;
|
|
993
988
|
* array: A;
|
|
994
|
-
* default?: ToType<T, A, false
|
|
989
|
+
* default?: ToType<T, A, false> | symbol;
|
|
995
990
|
* [k: string]: any;
|
|
996
991
|
* } & FieldDefineOption} options
|
|
997
992
|
* @returns {FieldDecorator<ToType<T, A, false>>}
|
|
@@ -999,7 +994,7 @@ declare function field$1<T extends keyof FieldType, A extends boolean>(type: T,
|
|
|
999
994
|
declare function field$1<T extends keyof FieldType, A extends boolean>(type: T, options: {
|
|
1000
995
|
nullable?: false;
|
|
1001
996
|
array: A;
|
|
1002
|
-
default?: ToType<T, A, false
|
|
997
|
+
default?: ToType<T, A, false> | symbol;
|
|
1003
998
|
[k: string]: any;
|
|
1004
999
|
} & FieldDefineOption): FieldDecorator<ToType<T, A, false>>;
|
|
1005
1000
|
/**
|
|
@@ -1010,7 +1005,7 @@ declare function field$1<T extends keyof FieldType, A extends boolean>(type: T,
|
|
|
1010
1005
|
* @param {{
|
|
1011
1006
|
* nullable: N;
|
|
1012
1007
|
* array?: false;
|
|
1013
|
-
* default?: ToType<T, false, N
|
|
1008
|
+
* default?: ToType<T, false, N> | symbol;
|
|
1014
1009
|
* [k: string]: any;
|
|
1015
1010
|
* } & FieldDefineOption} options
|
|
1016
1011
|
* @returns {FieldDecorator<ToType<T, false, N>>}
|
|
@@ -1018,7 +1013,7 @@ declare function field$1<T extends keyof FieldType, A extends boolean>(type: T,
|
|
|
1018
1013
|
declare function field$1<T extends keyof FieldType, N extends boolean>(type: T, options: {
|
|
1019
1014
|
nullable: N;
|
|
1020
1015
|
array?: false;
|
|
1021
|
-
default?: ToType<T, false, N
|
|
1016
|
+
default?: ToType<T, false, N> | symbol;
|
|
1022
1017
|
[k: string]: any;
|
|
1023
1018
|
} & FieldDefineOption): FieldDecorator<ToType<T, false, N>>;
|
|
1024
1019
|
/**
|
|
@@ -1029,7 +1024,7 @@ declare function field$1<T extends keyof FieldType, N extends boolean>(type: T,
|
|
|
1029
1024
|
* @param {{
|
|
1030
1025
|
* nullable: N;
|
|
1031
1026
|
* array: true;
|
|
1032
|
-
* default?: ToType<T, true, N
|
|
1027
|
+
* default?: ToType<T, true, N> | symbol;
|
|
1033
1028
|
* [k: string]: any;
|
|
1034
1029
|
* } & FieldDefineOption} options
|
|
1035
1030
|
* @returns {FieldDecorator<ToType<T, true, N>>}
|
|
@@ -1037,7 +1032,7 @@ declare function field$1<T extends keyof FieldType, N extends boolean>(type: T,
|
|
|
1037
1032
|
declare function field$1<T extends keyof FieldType, N extends boolean>(type: T, options: {
|
|
1038
1033
|
nullable: N;
|
|
1039
1034
|
array: true;
|
|
1040
|
-
default?: ToType<T, true, N
|
|
1035
|
+
default?: ToType<T, true, N> | symbol;
|
|
1041
1036
|
[k: string]: any;
|
|
1042
1037
|
} & FieldDefineOption): FieldDecorator<ToType<T, true, N>>;
|
|
1043
1038
|
/**
|
|
@@ -1048,14 +1043,14 @@ declare function field$1<T extends keyof FieldType, N extends boolean>(type: T,
|
|
|
1048
1043
|
* @param {true} array
|
|
1049
1044
|
* @param {{
|
|
1050
1045
|
* nullable: N;
|
|
1051
|
-
* default?: ToType<T, true, N
|
|
1046
|
+
* default?: ToType<T, true, N> | symbol;
|
|
1052
1047
|
* [k: string]: any;
|
|
1053
1048
|
* } & FieldDefineOption} options
|
|
1054
1049
|
* @returns {FieldDecorator<ToType<T, true, N>>}
|
|
1055
1050
|
*/
|
|
1056
1051
|
declare function field$1<T extends keyof FieldType, N extends boolean>(type: T, array: true, options: {
|
|
1057
1052
|
nullable: N;
|
|
1058
|
-
default?: ToType<T, true, N
|
|
1053
|
+
default?: ToType<T, true, N> | symbol;
|
|
1059
1054
|
[k: string]: any;
|
|
1060
1055
|
} & FieldDefineOption): FieldDecorator<ToType<T, true, N>>;
|
|
1061
1056
|
/**
|
|
@@ -1067,7 +1062,7 @@ declare function field$1<T extends keyof FieldType, N extends boolean>(type: T,
|
|
|
1067
1062
|
* @param {{
|
|
1068
1063
|
* nullable: N;
|
|
1069
1064
|
* array: A;
|
|
1070
|
-
* default?: ToType<T, A, N
|
|
1065
|
+
* default?: ToType<T, A, N> | symbol;
|
|
1071
1066
|
* [k: string]: any;
|
|
1072
1067
|
* } & FieldDefineOption} options
|
|
1073
1068
|
* @returns {FieldDecorator<ToType<T, A, N>>}
|
|
@@ -1075,7 +1070,7 @@ declare function field$1<T extends keyof FieldType, N extends boolean>(type: T,
|
|
|
1075
1070
|
declare function field$1<T extends keyof FieldType, A extends boolean, N extends boolean>(type: T, options: {
|
|
1076
1071
|
nullable: N;
|
|
1077
1072
|
array: A;
|
|
1078
|
-
default?: ToType<T, A, N
|
|
1073
|
+
default?: ToType<T, A, N> | symbol;
|
|
1079
1074
|
[k: string]: any;
|
|
1080
1075
|
} & FieldDefineOption): FieldDecorator<ToType<T, A, N>>;
|
|
1081
1076
|
/**
|
|
@@ -1085,7 +1080,7 @@ declare function field$1<T extends keyof FieldType, A extends boolean, N extends
|
|
|
1085
1080
|
* @param {{
|
|
1086
1081
|
* nullable?: boolean;
|
|
1087
1082
|
* array?: boolean;
|
|
1088
|
-
* default?: ToType<T, boolean, boolean
|
|
1083
|
+
* default?: ToType<T, boolean, boolean> | symbol;
|
|
1089
1084
|
* [k: string]: any;
|
|
1090
1085
|
* } & FieldDefineOption} options
|
|
1091
1086
|
* @returns {FieldDecorator<ToType<T, boolean, boolean>>}
|
|
@@ -1093,7 +1088,7 @@ declare function field$1<T extends keyof FieldType, A extends boolean, N extends
|
|
|
1093
1088
|
declare function field$1<T extends keyof FieldType>(type: T, options: {
|
|
1094
1089
|
nullable?: boolean;
|
|
1095
1090
|
array?: boolean;
|
|
1096
|
-
default?: ToType<T, boolean, boolean
|
|
1091
|
+
default?: ToType<T, boolean, boolean> | symbol;
|
|
1097
1092
|
[k: string]: any;
|
|
1098
1093
|
} & FieldDefineOption): FieldDecorator<ToType<T, boolean, boolean>>;
|
|
1099
1094
|
|
|
@@ -2169,14 +2164,14 @@ declare class Submodel {
|
|
|
2169
2164
|
* @param {{
|
|
2170
2165
|
* nullable?: false;
|
|
2171
2166
|
* array?: false;
|
|
2172
|
-
* default?: ToType<T, false, false
|
|
2167
|
+
* default?: ToType<T, false, false> | symbol;
|
|
2173
2168
|
* } & FieldDefineOption} [options]
|
|
2174
2169
|
* @returns {FieldDefine<T, false, false>}
|
|
2175
2170
|
*/
|
|
2176
2171
|
declare function field<T extends MainFieldType>(type: T, options?: ({
|
|
2177
2172
|
nullable?: false;
|
|
2178
2173
|
array?: false;
|
|
2179
|
-
default?: ToType<T, false, false
|
|
2174
|
+
default?: ToType<T, false, false> | symbol;
|
|
2180
2175
|
} & FieldDefineOption) | undefined): FieldDefine<T, false, false>;
|
|
2181
2176
|
/**
|
|
2182
2177
|
* @template {MainFieldType} T
|
|
@@ -2185,14 +2180,14 @@ declare function field<T extends MainFieldType>(type: T, options?: ({
|
|
|
2185
2180
|
* @param {{
|
|
2186
2181
|
* nullable?: false;
|
|
2187
2182
|
* array: true;
|
|
2188
|
-
* default?: ToType<T, true, false
|
|
2183
|
+
* default?: ToType<T, true, false> | symbol;
|
|
2189
2184
|
* } & FieldDefineOption} options
|
|
2190
2185
|
* @returns {FieldDefine<T, true, false>}
|
|
2191
2186
|
*/
|
|
2192
2187
|
declare function field<T extends MainFieldType>(type: T, options: {
|
|
2193
2188
|
nullable?: false;
|
|
2194
2189
|
array: true;
|
|
2195
|
-
default?: ToType<T, true, false
|
|
2190
|
+
default?: ToType<T, true, false> | symbol;
|
|
2196
2191
|
} & FieldDefineOption): FieldDefine<T, true, false>;
|
|
2197
2192
|
/**
|
|
2198
2193
|
* @template {MainFieldType} T
|
|
@@ -2201,14 +2196,14 @@ declare function field<T extends MainFieldType>(type: T, options: {
|
|
|
2201
2196
|
* @param {{
|
|
2202
2197
|
* nullable: true;
|
|
2203
2198
|
* array?: false;
|
|
2204
|
-
* default?: ToType<T, false, true
|
|
2199
|
+
* default?: ToType<T, false, true> | symbol;
|
|
2205
2200
|
* } & FieldDefineOption} options
|
|
2206
2201
|
* @returns {FieldDefine<T, false, true>}
|
|
2207
2202
|
*/
|
|
2208
2203
|
declare function field<T extends MainFieldType>(type: T, options: {
|
|
2209
2204
|
nullable: true;
|
|
2210
2205
|
array?: false;
|
|
2211
|
-
default?: ToType<T, false, true
|
|
2206
|
+
default?: ToType<T, false, true> | symbol;
|
|
2212
2207
|
} & FieldDefineOption): FieldDefine<T, false, true>;
|
|
2213
2208
|
/**
|
|
2214
2209
|
* @template {MainFieldType} T
|
|
@@ -2217,14 +2212,14 @@ declare function field<T extends MainFieldType>(type: T, options: {
|
|
|
2217
2212
|
* @param {{
|
|
2218
2213
|
* nullable: true;
|
|
2219
2214
|
* array: true;
|
|
2220
|
-
* default?: ToType<T, true, true
|
|
2215
|
+
* default?: ToType<T, true, true> | symbol;
|
|
2221
2216
|
* } & FieldDefineOption} options
|
|
2222
2217
|
* @returns {FieldDefine<T, true, true>}
|
|
2223
2218
|
*/
|
|
2224
2219
|
declare function field<T extends MainFieldType>(type: T, options: {
|
|
2225
2220
|
nullable: true;
|
|
2226
2221
|
array: true;
|
|
2227
|
-
default?: ToType<T, true, true
|
|
2222
|
+
default?: ToType<T, true, true> | symbol;
|
|
2228
2223
|
} & FieldDefineOption): FieldDefine<T, true, true>;
|
|
2229
2224
|
/**
|
|
2230
2225
|
* @template {MainFieldType} T
|
|
@@ -2234,14 +2229,14 @@ declare function field<T extends MainFieldType>(type: T, options: {
|
|
|
2234
2229
|
* @param {{
|
|
2235
2230
|
* nullable: true;
|
|
2236
2231
|
* array: A;
|
|
2237
|
-
* default?: ToType<T, A, true
|
|
2232
|
+
* default?: ToType<T, A, true> | symbol;
|
|
2238
2233
|
* } & FieldDefineOption} options
|
|
2239
2234
|
* @returns {FieldDefine<T, A, true>}
|
|
2240
2235
|
*/
|
|
2241
2236
|
declare function field<T extends MainFieldType, A extends boolean>(type: T, options: {
|
|
2242
2237
|
nullable: true;
|
|
2243
2238
|
array: A;
|
|
2244
|
-
default?: ToType<T, A, true
|
|
2239
|
+
default?: ToType<T, A, true> | symbol;
|
|
2245
2240
|
} & FieldDefineOption): FieldDefine<T, A, true>;
|
|
2246
2241
|
/**
|
|
2247
2242
|
* @template {MainFieldType} T
|
|
@@ -2251,14 +2246,14 @@ declare function field<T extends MainFieldType, A extends boolean>(type: T, opti
|
|
|
2251
2246
|
* @param {{
|
|
2252
2247
|
* nullable?: false;
|
|
2253
2248
|
* array: A;
|
|
2254
|
-
* default?: ToType<T, A, false
|
|
2249
|
+
* default?: ToType<T, A, false> | symbol;
|
|
2255
2250
|
* } & FieldDefineOption} options
|
|
2256
2251
|
* @returns {FieldDefine<T, A, false>}
|
|
2257
2252
|
*/
|
|
2258
2253
|
declare function field<T extends MainFieldType, A extends boolean>(type: T, options: {
|
|
2259
2254
|
nullable?: false;
|
|
2260
2255
|
array: A;
|
|
2261
|
-
default?: ToType<T, A, false
|
|
2256
|
+
default?: ToType<T, A, false> | symbol;
|
|
2262
2257
|
} & FieldDefineOption): FieldDefine<T, A, false>;
|
|
2263
2258
|
/**
|
|
2264
2259
|
* @template {MainFieldType} T
|
|
@@ -2268,14 +2263,14 @@ declare function field<T extends MainFieldType, A extends boolean>(type: T, opti
|
|
|
2268
2263
|
* @param {{
|
|
2269
2264
|
* nullable: N;
|
|
2270
2265
|
* array?: false;
|
|
2271
|
-
* default?: ToType<T, false, N
|
|
2266
|
+
* default?: ToType<T, false, N> | symbol;
|
|
2272
2267
|
* } & FieldDefineOption} options
|
|
2273
2268
|
* @returns {FieldDefine<T, false, N>}
|
|
2274
2269
|
*/
|
|
2275
2270
|
declare function field<T extends MainFieldType, N extends boolean>(type: T, options: {
|
|
2276
2271
|
nullable: N;
|
|
2277
2272
|
array?: false;
|
|
2278
|
-
default?: ToType<T, false, N
|
|
2273
|
+
default?: ToType<T, false, N> | symbol;
|
|
2279
2274
|
} & FieldDefineOption): FieldDefine<T, false, N>;
|
|
2280
2275
|
/**
|
|
2281
2276
|
* @template {MainFieldType} T
|
|
@@ -2285,14 +2280,14 @@ declare function field<T extends MainFieldType, N extends boolean>(type: T, opti
|
|
|
2285
2280
|
* @param {{
|
|
2286
2281
|
* nullable: N;
|
|
2287
2282
|
* array: true;
|
|
2288
|
-
* default?: ToType<T, true, N
|
|
2283
|
+
* default?: ToType<T, true, N> | symbol;
|
|
2289
2284
|
* } & FieldDefineOption} options
|
|
2290
2285
|
* @returns {FieldDefine<T, true, N>}
|
|
2291
2286
|
*/
|
|
2292
2287
|
declare function field<T extends MainFieldType, N extends boolean>(type: T, options: {
|
|
2293
2288
|
nullable: N;
|
|
2294
2289
|
array: true;
|
|
2295
|
-
default?: ToType<T, true, N
|
|
2290
|
+
default?: ToType<T, true, N> | symbol;
|
|
2296
2291
|
} & FieldDefineOption): FieldDefine<T, true, N>;
|
|
2297
2292
|
/**
|
|
2298
2293
|
* @template {MainFieldType} T
|
|
@@ -2303,14 +2298,14 @@ declare function field<T extends MainFieldType, N extends boolean>(type: T, opti
|
|
|
2303
2298
|
* @param {{
|
|
2304
2299
|
* nullable: N;
|
|
2305
2300
|
* array: A;
|
|
2306
|
-
* default?: ToType<T, A, N
|
|
2301
|
+
* default?: ToType<T, A, N> | symbol;
|
|
2307
2302
|
* } & FieldDefineOption} options
|
|
2308
2303
|
* @returns {FieldDefine<T, A, N>}
|
|
2309
2304
|
*/
|
|
2310
2305
|
declare function field<T extends MainFieldType, A extends boolean, N extends boolean>(type: T, options: {
|
|
2311
2306
|
nullable: N;
|
|
2312
2307
|
array: A;
|
|
2313
|
-
default?: ToType<T, A, N
|
|
2308
|
+
default?: ToType<T, A, N> | symbol;
|
|
2314
2309
|
} & FieldDefineOption): FieldDefine<T, A, N>;
|
|
2315
2310
|
/**
|
|
2316
2311
|
* @template {MainFieldType} T
|
|
@@ -2319,14 +2314,14 @@ declare function field<T extends MainFieldType, A extends boolean, N extends boo
|
|
|
2319
2314
|
* @param {{
|
|
2320
2315
|
* nullable?: boolean;
|
|
2321
2316
|
* array?: boolean;
|
|
2322
|
-
* default?: ToType<T, boolean, boolean
|
|
2317
|
+
* default?: ToType<T, boolean, boolean> | symbol;
|
|
2323
2318
|
* } & FieldDefineOption} options
|
|
2324
2319
|
* @returns {FieldDefine<T, boolean, boolean>}
|
|
2325
2320
|
*/
|
|
2326
2321
|
declare function field<T extends MainFieldType>(type: T, options: {
|
|
2327
2322
|
nullable?: boolean;
|
|
2328
2323
|
array?: boolean;
|
|
2329
|
-
default?: ToType<T, boolean, boolean
|
|
2324
|
+
default?: ToType<T, boolean, boolean> | symbol;
|
|
2330
2325
|
} & FieldDefineOption): FieldDefine<T, boolean, boolean>;
|
|
2331
2326
|
|
|
2332
2327
|
/**
|
package/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* imodel v0.
|
|
2
|
+
* imodel v0.13.0
|
|
3
3
|
* (c) 2019-2026 undefined
|
|
4
4
|
* @license undefined
|
|
5
5
|
*/
|
|
@@ -2215,7 +2215,7 @@ async function search(conn, that, p, env, returnFields, skip) {
|
|
|
2215
2215
|
const [columns, fieldColumns, tableFields] = toColumns(fields);
|
|
2216
2216
|
const where = where2column(options.where, fieldColumns);
|
|
2217
2217
|
where.push(...getFixedValueWhere(columns));
|
|
2218
|
-
const whereHook = !skip?.where && (await p.hooks?.where?.(that));
|
|
2218
|
+
const whereHook = !skip?.where && (await p.hooks?.where?.(that, p));
|
|
2219
2219
|
if (whereHook) {
|
|
2220
2220
|
where.push(...where2column(Where.parse(whereHook), fieldColumns));
|
|
2221
2221
|
}
|
|
@@ -2270,7 +2270,7 @@ async function first(conn, that, p, env, skip) {
|
|
|
2270
2270
|
const [columns, fieldColumns, tableFields] = toColumns(fields);
|
|
2271
2271
|
const where = where2column(options.where, fieldColumns);
|
|
2272
2272
|
where.push(...getFixedValueWhere(columns));
|
|
2273
|
-
const whereHook = !skip?.where && (await p.hooks?.where?.(that));
|
|
2273
|
+
const whereHook = !skip?.where && (await p.hooks?.where?.(that, p));
|
|
2274
2274
|
if (whereHook) {
|
|
2275
2275
|
where.push(...where2column(Where.parse(whereHook), fieldColumns));
|
|
2276
2276
|
}
|
|
@@ -2618,11 +2618,11 @@ class Connection {
|
|
|
2618
2618
|
let setData = list;
|
|
2619
2619
|
if (typeof beforeCreateMany === 'function') {
|
|
2620
2620
|
// @ts-ignore
|
|
2621
|
-
setData = (await beforeCreateMany.call(setData, this, setData)) || setData;
|
|
2621
|
+
setData = (await beforeCreateMany.call(setData, this, model, setData)) || setData;
|
|
2622
2622
|
}
|
|
2623
2623
|
const r = await create(conn, this.#env, model, setData, skip, md);
|
|
2624
2624
|
if (typeof afterCreateMany === 'function') {
|
|
2625
|
-
await afterCreateMany.call(r, this, r);
|
|
2625
|
+
await afterCreateMany.call(r, this, model, r);
|
|
2626
2626
|
}
|
|
2627
2627
|
return r;
|
|
2628
2628
|
}
|
|
@@ -2633,11 +2633,11 @@ class Connection {
|
|
|
2633
2633
|
const conn = await this.#getConnection();
|
|
2634
2634
|
let setData = data;
|
|
2635
2635
|
if (typeof beforeCreate === 'function') {
|
|
2636
|
-
setData = (await beforeCreate.call(setData, this, setData)) || setData;
|
|
2636
|
+
setData = (await beforeCreate.call(setData, this, model, setData)) || setData;
|
|
2637
2637
|
}
|
|
2638
2638
|
const result = await create(conn, this.#env, model, setData, skip, md);
|
|
2639
2639
|
if (typeof afterCreate === 'function') {
|
|
2640
|
-
await afterCreate.call(result, this, result);
|
|
2640
|
+
await afterCreate.call(result, this, model, result);
|
|
2641
2641
|
}
|
|
2642
2642
|
return isArray ? [result] : result;
|
|
2643
2643
|
}
|
|
@@ -2647,11 +2647,11 @@ class Connection {
|
|
|
2647
2647
|
let setData = data;
|
|
2648
2648
|
const conn = await this.#getConnection();
|
|
2649
2649
|
if (typeof beforeCreate === 'function') {
|
|
2650
|
-
setData = (await beforeCreate.call(that ?? setData, this, setData)) || setData;
|
|
2650
|
+
setData = (await beforeCreate.call(that ?? setData, this, model, setData)) || setData;
|
|
2651
2651
|
}
|
|
2652
2652
|
const r = await create(conn, this.#env, model, setData, skip);
|
|
2653
2653
|
if (typeof afterCreate === 'function') {
|
|
2654
|
-
await afterCreate.call(that ?? r, this, r);
|
|
2654
|
+
await afterCreate.call(that ?? r, this, model, r);
|
|
2655
2655
|
}
|
|
2656
2656
|
return r;
|
|
2657
2657
|
}, model);
|
|
@@ -2722,14 +2722,14 @@ class Connection {
|
|
|
2722
2722
|
let setData = newData;
|
|
2723
2723
|
if (typeof beforeUpdate === 'function') {
|
|
2724
2724
|
// @ts-ignore
|
|
2725
|
-
setData = (await beforeUpdate.call(data, this, data, setData)) || setData;
|
|
2725
|
+
setData = (await beforeUpdate.call(data, this, model, data, setData)) || setData;
|
|
2726
2726
|
}
|
|
2727
2727
|
// @ts-ignore
|
|
2728
2728
|
const r = await updateData(conn, model, data, setData, this.#env, skip);
|
|
2729
2729
|
if (r) {
|
|
2730
2730
|
if (typeof afterUpdate === 'function') {
|
|
2731
2731
|
// @ts-ignore
|
|
2732
|
-
await afterUpdate.call(r, this, r, data);
|
|
2732
|
+
await afterUpdate.call(r, this, model, r, data);
|
|
2733
2733
|
}
|
|
2734
2734
|
}
|
|
2735
2735
|
// @ts-ignore
|
|
@@ -2739,11 +2739,11 @@ class Connection {
|
|
|
2739
2739
|
// @ts-ignore
|
|
2740
2740
|
let setData = data;
|
|
2741
2741
|
if (typeof beforeCreate === 'function') {
|
|
2742
|
-
setData = (await beforeCreate.call(data, this, setData)) || setData;
|
|
2742
|
+
setData = (await beforeCreate.call(data, this, model, setData)) || setData;
|
|
2743
2743
|
}
|
|
2744
2744
|
const r = await create(conn, this.#env, model, setData, skip);
|
|
2745
2745
|
if (typeof afterCreate === 'function') {
|
|
2746
|
-
await afterCreate.call(r, this, r);
|
|
2746
|
+
await afterCreate.call(r, this, model, r);
|
|
2747
2747
|
}
|
|
2748
2748
|
return r;
|
|
2749
2749
|
}
|
|
@@ -2754,23 +2754,23 @@ class Connection {
|
|
|
2754
2754
|
if (newData) {
|
|
2755
2755
|
let setData = newData;
|
|
2756
2756
|
if (typeof beforeUpdate === 'function') {
|
|
2757
|
-
setData = (await beforeUpdate.call(that, this, data, setData)) || setData;
|
|
2757
|
+
setData = (await beforeUpdate.call(that, this, model, data, setData)) || setData;
|
|
2758
2758
|
}
|
|
2759
2759
|
const r = await updateData(conn, model, data, setData, this.#env, skip);
|
|
2760
2760
|
if (r) {
|
|
2761
2761
|
if (typeof afterUpdate === 'function') {
|
|
2762
|
-
await afterUpdate.call(that, this, r, data);
|
|
2762
|
+
await afterUpdate.call(that, this, model, r, data);
|
|
2763
2763
|
}
|
|
2764
2764
|
}
|
|
2765
2765
|
return r;
|
|
2766
2766
|
}
|
|
2767
2767
|
let setData = data;
|
|
2768
2768
|
if (typeof beforeCreate === 'function') {
|
|
2769
|
-
setData = (await beforeCreate.call(that, this, setData)) || setData;
|
|
2769
|
+
setData = (await beforeCreate.call(that, this, model, setData)) || setData;
|
|
2770
2770
|
}
|
|
2771
2771
|
const r = await create(conn, this.#env, model, setData, skip);
|
|
2772
2772
|
if (typeof afterCreate === 'function') {
|
|
2773
|
-
await afterCreate.call(that, this, r);
|
|
2773
|
+
await afterCreate.call(that, this, model, r);
|
|
2774
2774
|
}
|
|
2775
2775
|
return r;
|
|
2776
2776
|
}, newData || null, model);
|
|
@@ -2791,12 +2791,12 @@ class Connection {
|
|
|
2791
2791
|
const conn = await this.#getConnection();
|
|
2792
2792
|
if (typeof beforeDelete === 'function') {
|
|
2793
2793
|
// @ts-ignore
|
|
2794
|
-
await beforeDelete.call(data, this, data, null);
|
|
2794
|
+
await beforeDelete.call(data, this, tableDef, data, null);
|
|
2795
2795
|
}
|
|
2796
2796
|
const r = await completelyDelete(conn, tableDef, data, this.#env);
|
|
2797
2797
|
if (r && typeof afterDelete === 'function') {
|
|
2798
2798
|
// @ts-ignore
|
|
2799
|
-
await afterDelete.call(r, this, data, null);
|
|
2799
|
+
await afterDelete.call(r, this, tableDef, data, null);
|
|
2800
2800
|
}
|
|
2801
2801
|
return r;
|
|
2802
2802
|
}
|
|
@@ -2805,11 +2805,11 @@ class Connection {
|
|
|
2805
2805
|
return that[Destroy](this, async data => {
|
|
2806
2806
|
const conn = await this.#getConnection();
|
|
2807
2807
|
if (typeof beforeDelete === 'function') {
|
|
2808
|
-
await beforeDelete.call(that, this, data, null);
|
|
2808
|
+
await beforeDelete.call(that, this, tableDef, data, null);
|
|
2809
2809
|
}
|
|
2810
2810
|
const r = await completelyDelete(conn, tableDef, data, this.#env);
|
|
2811
2811
|
if (r && typeof afterDelete === 'function') {
|
|
2812
|
-
await afterDelete.call(that, this, data, null);
|
|
2812
|
+
await afterDelete.call(that, this, tableDef, data, null);
|
|
2813
2813
|
}
|
|
2814
2814
|
return r;
|
|
2815
2815
|
}, tableDef);
|
|
@@ -2837,12 +2837,12 @@ class Connection {
|
|
|
2837
2837
|
const conn = await this.#getConnection();
|
|
2838
2838
|
if (typeof beforeDelete === 'function') {
|
|
2839
2839
|
// @ts-ignore
|
|
2840
|
-
await beforeDelete.call(data, this, data, update);
|
|
2840
|
+
await beforeDelete.call(data, this, tableDef, data, update);
|
|
2841
2841
|
}
|
|
2842
2842
|
const r = await pseudoDestroy(conn, tableDef, data, update, this.#env);
|
|
2843
2843
|
if (r && typeof afterDelete === 'function') {
|
|
2844
2844
|
// @ts-ignore
|
|
2845
|
-
await afterDelete.call(r, this, data, update);
|
|
2845
|
+
await afterDelete.call(r, this, tableDef, data, update);
|
|
2846
2846
|
}
|
|
2847
2847
|
// @ts-ignore
|
|
2848
2848
|
return r;
|
|
@@ -2852,11 +2852,11 @@ class Connection {
|
|
|
2852
2852
|
return that[PseudoDestroy](this, update, async data => {
|
|
2853
2853
|
const conn = await this.#getConnection();
|
|
2854
2854
|
if (typeof beforeDelete === 'function') {
|
|
2855
|
-
await beforeDelete.call(that, this, data, update);
|
|
2855
|
+
await beforeDelete.call(that, this, tableDef, data, update);
|
|
2856
2856
|
}
|
|
2857
2857
|
const r = await pseudoDestroy(conn, tableDef, data, update, this.#env);
|
|
2858
2858
|
if (r && typeof afterDelete === 'function') {
|
|
2859
|
-
await afterDelete.call(that, this, data, update);
|
|
2859
|
+
await afterDelete.call(that, this, tableDef, data, update);
|
|
2860
2860
|
}
|
|
2861
2861
|
// @ts-ignore
|
|
2862
2862
|
return r;
|
|
@@ -3582,7 +3582,7 @@ function buildHooks(Model) {
|
|
|
3582
3582
|
[afterDeleteMetaKey]: afterDeleteMeta
|
|
3583
3583
|
} = metadata;
|
|
3584
3584
|
return {
|
|
3585
|
-
async where(conn) {
|
|
3585
|
+
async where(conn, model) {
|
|
3586
3586
|
let that;
|
|
3587
3587
|
for (const {
|
|
3588
3588
|
hook
|
|
@@ -3590,14 +3590,14 @@ function buildHooks(Model) {
|
|
|
3590
3590
|
if (typeof hook !== 'function') {
|
|
3591
3591
|
continue;
|
|
3592
3592
|
}
|
|
3593
|
-
const where = await hook.call(Model, conn);
|
|
3593
|
+
const where = await hook.call(Model, conn, model);
|
|
3594
3594
|
if (where) {
|
|
3595
3595
|
that = (that || Where).and(where);
|
|
3596
3596
|
}
|
|
3597
3597
|
}
|
|
3598
3598
|
return that;
|
|
3599
3599
|
},
|
|
3600
|
-
async beforeCreateMany(conn, record) {
|
|
3600
|
+
async beforeCreateMany(conn, model, record) {
|
|
3601
3601
|
let data = record;
|
|
3602
3602
|
for (const {
|
|
3603
3603
|
hook
|
|
@@ -3605,21 +3605,21 @@ function buildHooks(Model) {
|
|
|
3605
3605
|
if (typeof hook !== 'function') {
|
|
3606
3606
|
continue;
|
|
3607
3607
|
}
|
|
3608
|
-
data = (await hook.call(Model, conn, data)) || data;
|
|
3608
|
+
data = (await hook.call(Model, conn, model, data)) || data;
|
|
3609
3609
|
}
|
|
3610
3610
|
return data;
|
|
3611
3611
|
},
|
|
3612
|
-
async afterCreateMany(conn, record) {
|
|
3612
|
+
async afterCreateMany(conn, model, record) {
|
|
3613
3613
|
for (const {
|
|
3614
3614
|
hook
|
|
3615
3615
|
} of flatHook(afterCreateManyMeta)) {
|
|
3616
3616
|
if (typeof hook !== 'function') {
|
|
3617
3617
|
continue;
|
|
3618
3618
|
}
|
|
3619
|
-
await hook.call(Model, conn, record);
|
|
3619
|
+
await hook.call(Model, conn, model, record);
|
|
3620
3620
|
}
|
|
3621
3621
|
},
|
|
3622
|
-
async beforeCreate(conn, record) {
|
|
3622
|
+
async beforeCreate(conn, model, record) {
|
|
3623
3623
|
let that;
|
|
3624
3624
|
let data = record;
|
|
3625
3625
|
for (const {
|
|
@@ -3630,11 +3630,11 @@ function buildHooks(Model) {
|
|
|
3630
3630
|
continue;
|
|
3631
3631
|
}
|
|
3632
3632
|
const thisArg = isStatic ? Model : that ||= this instanceof Model ? this : new Model(record);
|
|
3633
|
-
data = (await hook.call(thisArg, conn, data)) || data;
|
|
3633
|
+
data = (await hook.call(thisArg, conn, model, data)) || data;
|
|
3634
3634
|
}
|
|
3635
3635
|
return data;
|
|
3636
3636
|
},
|
|
3637
|
-
async afterCreate(conn, record) {
|
|
3637
|
+
async afterCreate(conn, model, record) {
|
|
3638
3638
|
let that;
|
|
3639
3639
|
for (const {
|
|
3640
3640
|
static: isStatic,
|
|
@@ -3644,10 +3644,10 @@ function buildHooks(Model) {
|
|
|
3644
3644
|
continue;
|
|
3645
3645
|
}
|
|
3646
3646
|
const thisArg = isStatic ? Model : that ||= this instanceof Model ? this : new Model(record, true);
|
|
3647
|
-
await hook.call(thisArg, conn, record);
|
|
3647
|
+
await hook.call(thisArg, conn, model, record);
|
|
3648
3648
|
}
|
|
3649
3649
|
},
|
|
3650
|
-
async beforeUpdate(conn, record, set) {
|
|
3650
|
+
async beforeUpdate(conn, model, record, set) {
|
|
3651
3651
|
let that;
|
|
3652
3652
|
let data = set;
|
|
3653
3653
|
for (const {
|
|
@@ -3658,11 +3658,11 @@ function buildHooks(Model) {
|
|
|
3658
3658
|
continue;
|
|
3659
3659
|
}
|
|
3660
3660
|
const thisArg = isStatic ? Model : that ||= this instanceof Model ? this : new Model(record, set);
|
|
3661
|
-
data = (await hook.call(thisArg, conn, record, data)) || data;
|
|
3661
|
+
data = (await hook.call(thisArg, conn, model, record, data)) || data;
|
|
3662
3662
|
}
|
|
3663
3663
|
return data;
|
|
3664
3664
|
},
|
|
3665
|
-
async afterUpdate(conn, record, oldRecord) {
|
|
3665
|
+
async afterUpdate(conn, model, record, oldRecord) {
|
|
3666
3666
|
let that;
|
|
3667
3667
|
for (const {
|
|
3668
3668
|
static: isStatic,
|
|
@@ -3672,10 +3672,10 @@ function buildHooks(Model) {
|
|
|
3672
3672
|
continue;
|
|
3673
3673
|
}
|
|
3674
3674
|
const thisArg = isStatic ? Model : that ||= this instanceof Model ? this : new Model(record, true);
|
|
3675
|
-
await hook.call(thisArg, conn, record, oldRecord);
|
|
3675
|
+
await hook.call(thisArg, conn, model, record, oldRecord);
|
|
3676
3676
|
}
|
|
3677
3677
|
},
|
|
3678
|
-
async beforeDelete(conn, record, update) {
|
|
3678
|
+
async beforeDelete(conn, model, record, update) {
|
|
3679
3679
|
let that;
|
|
3680
3680
|
for (const {
|
|
3681
3681
|
static: isStatic,
|
|
@@ -3685,10 +3685,10 @@ function buildHooks(Model) {
|
|
|
3685
3685
|
continue;
|
|
3686
3686
|
}
|
|
3687
3687
|
const thisArg = isStatic ? Model : that ||= this instanceof Model ? this : new Model(record, true);
|
|
3688
|
-
await hook.call(thisArg, conn, record, update);
|
|
3688
|
+
await hook.call(thisArg, conn, model, record, update);
|
|
3689
3689
|
}
|
|
3690
3690
|
},
|
|
3691
|
-
async afterDelete(conn, record, update) {
|
|
3691
|
+
async afterDelete(conn, model, record, update) {
|
|
3692
3692
|
let that;
|
|
3693
3693
|
for (const {
|
|
3694
3694
|
static: isStatic,
|
|
@@ -3698,7 +3698,7 @@ function buildHooks(Model) {
|
|
|
3698
3698
|
continue;
|
|
3699
3699
|
}
|
|
3700
3700
|
const thisArg = isStatic ? Model : that ||= this instanceof Model ? this : new Model(record, true);
|
|
3701
|
-
await hook.call(thisArg, conn, record, update);
|
|
3701
|
+
await hook.call(thisArg, conn, model, record, update);
|
|
3702
3702
|
}
|
|
3703
3703
|
}
|
|
3704
3704
|
};
|
|
@@ -3987,7 +3987,7 @@ function model(type, constraints, p1, p2) {
|
|
|
3987
3987
|
* @param {{
|
|
3988
3988
|
* nullable?: false;
|
|
3989
3989
|
* array?: false;
|
|
3990
|
-
* default?: ToType<T, false, false
|
|
3990
|
+
* default?: ToType<T, false, false> | symbol;
|
|
3991
3991
|
* [k: string]: any;
|
|
3992
3992
|
* } & FieldDefineOption} [options]
|
|
3993
3993
|
* @returns {FieldDecorator<ToType<T, false, false>>}
|
|
@@ -3999,7 +3999,7 @@ function model(type, constraints, p1, p2) {
|
|
|
3999
3999
|
* @param {{
|
|
4000
4000
|
* nullable?: false;
|
|
4001
4001
|
* array: true;
|
|
4002
|
-
* default?: ToType<T, true, false
|
|
4002
|
+
* default?: ToType<T, true, false> | symbol;
|
|
4003
4003
|
* [k: string]: any;
|
|
4004
4004
|
* } & FieldDefineOption} options
|
|
4005
4005
|
* @returns {FieldDecorator<ToType<T, true, false>>}
|
|
@@ -4011,7 +4011,7 @@ function model(type, constraints, p1, p2) {
|
|
|
4011
4011
|
* @param {true} array
|
|
4012
4012
|
* @param {{
|
|
4013
4013
|
* nullable?: false;
|
|
4014
|
-
* default?: ToType<T, true, false
|
|
4014
|
+
* default?: ToType<T, true, false> | symbol;
|
|
4015
4015
|
* [k: string]: any;
|
|
4016
4016
|
* } & FieldDefineOption} options
|
|
4017
4017
|
* @returns {FieldDecorator<ToType<T, true, false>>}
|
|
@@ -4023,7 +4023,7 @@ function model(type, constraints, p1, p2) {
|
|
|
4023
4023
|
* @param {{
|
|
4024
4024
|
* nullable: true;
|
|
4025
4025
|
* array?: false;
|
|
4026
|
-
* default?: ToType<T, false, true
|
|
4026
|
+
* default?: ToType<T, false, true> | symbol;
|
|
4027
4027
|
* [k: string]: any;
|
|
4028
4028
|
* } & FieldDefineOption} options
|
|
4029
4029
|
* @returns {FieldDecorator<ToType<T, false, true>>}
|
|
@@ -4035,7 +4035,7 @@ function model(type, constraints, p1, p2) {
|
|
|
4035
4035
|
* @param {{
|
|
4036
4036
|
* nullable: true;
|
|
4037
4037
|
* array: true;
|
|
4038
|
-
* default?: ToType<T, true, true
|
|
4038
|
+
* default?: ToType<T, true, true> | symbol;
|
|
4039
4039
|
* [k: string]: any;
|
|
4040
4040
|
* } & FieldDefineOption} options
|
|
4041
4041
|
* @returns {FieldDecorator<ToType<T, true, true>>}
|
|
@@ -4047,7 +4047,7 @@ function model(type, constraints, p1, p2) {
|
|
|
4047
4047
|
* @param {true} array
|
|
4048
4048
|
* @param {{
|
|
4049
4049
|
* nullable: true;
|
|
4050
|
-
* default?: ToType<T, true, true
|
|
4050
|
+
* default?: ToType<T, true, true> | symbol;
|
|
4051
4051
|
* [k: string]: any;
|
|
4052
4052
|
* } & FieldDefineOption} options
|
|
4053
4053
|
* @returns {FieldDecorator<ToType<T, true, true>>}
|
|
@@ -4060,7 +4060,7 @@ function model(type, constraints, p1, p2) {
|
|
|
4060
4060
|
* @param {{
|
|
4061
4061
|
* nullable: true;
|
|
4062
4062
|
* array: A;
|
|
4063
|
-
* default?: ToType<T, A, true
|
|
4063
|
+
* default?: ToType<T, A, true> | symbol;
|
|
4064
4064
|
* [k: string]: any;
|
|
4065
4065
|
* } & FieldDefineOption} options
|
|
4066
4066
|
* @returns {FieldDecorator<ToType<T, A, true>>}
|
|
@@ -4073,7 +4073,7 @@ function model(type, constraints, p1, p2) {
|
|
|
4073
4073
|
* @param {{
|
|
4074
4074
|
* nullable?: false;
|
|
4075
4075
|
* array: A;
|
|
4076
|
-
* default?: ToType<T, A, false
|
|
4076
|
+
* default?: ToType<T, A, false> | symbol;
|
|
4077
4077
|
* [k: string]: any;
|
|
4078
4078
|
* } & FieldDefineOption} options
|
|
4079
4079
|
* @returns {FieldDecorator<ToType<T, A, false>>}
|
|
@@ -4086,7 +4086,7 @@ function model(type, constraints, p1, p2) {
|
|
|
4086
4086
|
* @param {{
|
|
4087
4087
|
* nullable: N;
|
|
4088
4088
|
* array?: false;
|
|
4089
|
-
* default?: ToType<T, false, N
|
|
4089
|
+
* default?: ToType<T, false, N> | symbol;
|
|
4090
4090
|
* [k: string]: any;
|
|
4091
4091
|
* } & FieldDefineOption} options
|
|
4092
4092
|
* @returns {FieldDecorator<ToType<T, false, N>>}
|
|
@@ -4099,7 +4099,7 @@ function model(type, constraints, p1, p2) {
|
|
|
4099
4099
|
* @param {{
|
|
4100
4100
|
* nullable: N;
|
|
4101
4101
|
* array: true;
|
|
4102
|
-
* default?: ToType<T, true, N
|
|
4102
|
+
* default?: ToType<T, true, N> | symbol;
|
|
4103
4103
|
* [k: string]: any;
|
|
4104
4104
|
* } & FieldDefineOption} options
|
|
4105
4105
|
* @returns {FieldDecorator<ToType<T, true, N>>}
|
|
@@ -4112,7 +4112,7 @@ function model(type, constraints, p1, p2) {
|
|
|
4112
4112
|
* @param {true} array
|
|
4113
4113
|
* @param {{
|
|
4114
4114
|
* nullable: N;
|
|
4115
|
-
* default?: ToType<T, true, N
|
|
4115
|
+
* default?: ToType<T, true, N> | symbol;
|
|
4116
4116
|
* [k: string]: any;
|
|
4117
4117
|
* } & FieldDefineOption} options
|
|
4118
4118
|
* @returns {FieldDecorator<ToType<T, true, N>>}
|
|
@@ -4126,7 +4126,7 @@ function model(type, constraints, p1, p2) {
|
|
|
4126
4126
|
* @param {{
|
|
4127
4127
|
* nullable: N;
|
|
4128
4128
|
* array: A;
|
|
4129
|
-
* default?: ToType<T, A, N
|
|
4129
|
+
* default?: ToType<T, A, N> | symbol;
|
|
4130
4130
|
* [k: string]: any;
|
|
4131
4131
|
* } & FieldDefineOption} options
|
|
4132
4132
|
* @returns {FieldDecorator<ToType<T, A, N>>}
|
|
@@ -4138,7 +4138,7 @@ function model(type, constraints, p1, p2) {
|
|
|
4138
4138
|
* @param {{
|
|
4139
4139
|
* nullable?: boolean;
|
|
4140
4140
|
* array?: boolean;
|
|
4141
|
-
* default?: ToType<T, boolean, boolean
|
|
4141
|
+
* default?: ToType<T, boolean, boolean> | symbol;
|
|
4142
4142
|
* [k: string]: any;
|
|
4143
4143
|
* } & FieldDefineOption} options
|
|
4144
4144
|
* @returns {FieldDecorator<ToType<T, boolean, boolean>>}
|
|
@@ -6073,7 +6073,7 @@ class Scene {
|
|
|
6073
6073
|
* @param {{
|
|
6074
6074
|
* nullable?: false;
|
|
6075
6075
|
* array?: false;
|
|
6076
|
-
* default?: ToType<T, false, false
|
|
6076
|
+
* default?: ToType<T, false, false> | symbol;
|
|
6077
6077
|
* } & FieldDefineOption} [options]
|
|
6078
6078
|
* @returns {FieldDefine<T, false, false>}
|
|
6079
6079
|
*/
|
|
@@ -6084,7 +6084,7 @@ class Scene {
|
|
|
6084
6084
|
* @param {{
|
|
6085
6085
|
* nullable?: false;
|
|
6086
6086
|
* array: true;
|
|
6087
|
-
* default?: ToType<T, true, false
|
|
6087
|
+
* default?: ToType<T, true, false> | symbol;
|
|
6088
6088
|
* } & FieldDefineOption} options
|
|
6089
6089
|
* @returns {FieldDefine<T, true, false>}
|
|
6090
6090
|
*/
|
|
@@ -6095,7 +6095,7 @@ class Scene {
|
|
|
6095
6095
|
* @param {{
|
|
6096
6096
|
* nullable: true;
|
|
6097
6097
|
* array?: false;
|
|
6098
|
-
* default?: ToType<T, false, true
|
|
6098
|
+
* default?: ToType<T, false, true> | symbol;
|
|
6099
6099
|
* } & FieldDefineOption} options
|
|
6100
6100
|
* @returns {FieldDefine<T, false, true>}
|
|
6101
6101
|
*/
|
|
@@ -6106,7 +6106,7 @@ class Scene {
|
|
|
6106
6106
|
* @param {{
|
|
6107
6107
|
* nullable: true;
|
|
6108
6108
|
* array: true;
|
|
6109
|
-
* default?: ToType<T, true, true
|
|
6109
|
+
* default?: ToType<T, true, true> | symbol;
|
|
6110
6110
|
* } & FieldDefineOption} options
|
|
6111
6111
|
* @returns {FieldDefine<T, true, true>}
|
|
6112
6112
|
*/
|
|
@@ -6118,7 +6118,7 @@ class Scene {
|
|
|
6118
6118
|
* @param {{
|
|
6119
6119
|
* nullable: true;
|
|
6120
6120
|
* array: A;
|
|
6121
|
-
* default?: ToType<T, A, true
|
|
6121
|
+
* default?: ToType<T, A, true> | symbol;
|
|
6122
6122
|
* } & FieldDefineOption} options
|
|
6123
6123
|
* @returns {FieldDefine<T, A, true>}
|
|
6124
6124
|
*/
|
|
@@ -6130,7 +6130,7 @@ class Scene {
|
|
|
6130
6130
|
* @param {{
|
|
6131
6131
|
* nullable?: false;
|
|
6132
6132
|
* array: A;
|
|
6133
|
-
* default?: ToType<T, A, false
|
|
6133
|
+
* default?: ToType<T, A, false> | symbol;
|
|
6134
6134
|
* } & FieldDefineOption} options
|
|
6135
6135
|
* @returns {FieldDefine<T, A, false>}
|
|
6136
6136
|
*/
|
|
@@ -6142,7 +6142,7 @@ class Scene {
|
|
|
6142
6142
|
* @param {{
|
|
6143
6143
|
* nullable: N;
|
|
6144
6144
|
* array?: false;
|
|
6145
|
-
* default?: ToType<T, false, N
|
|
6145
|
+
* default?: ToType<T, false, N> | symbol;
|
|
6146
6146
|
* } & FieldDefineOption} options
|
|
6147
6147
|
* @returns {FieldDefine<T, false, N>}
|
|
6148
6148
|
*/
|
|
@@ -6154,7 +6154,7 @@ class Scene {
|
|
|
6154
6154
|
* @param {{
|
|
6155
6155
|
* nullable: N;
|
|
6156
6156
|
* array: true;
|
|
6157
|
-
* default?: ToType<T, true, N
|
|
6157
|
+
* default?: ToType<T, true, N> | symbol;
|
|
6158
6158
|
* } & FieldDefineOption} options
|
|
6159
6159
|
* @returns {FieldDefine<T, true, N>}
|
|
6160
6160
|
*/
|
|
@@ -6167,7 +6167,7 @@ class Scene {
|
|
|
6167
6167
|
* @param {{
|
|
6168
6168
|
* nullable: N;
|
|
6169
6169
|
* array: A;
|
|
6170
|
-
* default?: ToType<T, A, N
|
|
6170
|
+
* default?: ToType<T, A, N> | symbol;
|
|
6171
6171
|
* } & FieldDefineOption} options
|
|
6172
6172
|
* @returns {FieldDefine<T, A, N>}
|
|
6173
6173
|
*/
|
|
@@ -6178,7 +6178,7 @@ class Scene {
|
|
|
6178
6178
|
* @param {{
|
|
6179
6179
|
* nullable?: boolean;
|
|
6180
6180
|
* array?: boolean;
|
|
6181
|
-
* default?: ToType<T, boolean, boolean
|
|
6181
|
+
* default?: ToType<T, boolean, boolean> | symbol;
|
|
6182
6182
|
* } & FieldDefineOption} options
|
|
6183
6183
|
* @returns {FieldDefine<T, boolean, boolean>}
|
|
6184
6184
|
*/
|
package/migrate.d.mts
CHANGED
package/migrate.mjs
CHANGED