ts-prorm-orm 2.0.0 → 2.1.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/CHANGELOG.md +132 -0
- package/dist/compliance/data-classifier.d.ts +6 -0
- package/dist/compliance/data-classifier.js +6 -0
- package/dist/compliance/data-lineage.d.ts +4 -0
- package/dist/compliance/data-lineage.js +4 -0
- package/dist/compliance/data-masker.d.ts +4 -0
- package/dist/compliance/data-masker.js +4 -0
- package/dist/compliance/index.d.ts +2 -0
- package/dist/compliance/index.js +2 -0
- package/dist/compliance/pseudonymization.d.ts +4 -0
- package/dist/compliance/pseudonymization.js +4 -0
- package/dist/compliance/query-firewall.d.ts +9 -9
- package/dist/compliance/query-firewall.js +9 -9
- package/dist/compliance/rate-limiter.d.ts +4 -0
- package/dist/compliance/rate-limiter.js +4 -0
- package/dist/compliance/row-level-security.d.ts +2 -0
- package/dist/compliance/row-level-security.js +2 -0
- package/dist/compliance/security-decorator.d.ts +8 -0
- package/dist/compliance/security-decorator.js +8 -0
- package/dist/compliance/session-isolation.d.ts +4 -0
- package/dist/compliance/session-isolation.js +4 -0
- package/dist/compliance/worm-storage.d.ts +4 -0
- package/dist/compliance/worm-storage.js +4 -0
- package/dist/decorators/audit.d.ts +3 -1
- package/dist/decorators/audit.js +3 -1
- package/dist/decorators/check.d.ts +15 -15
- package/dist/decorators/check.js +15 -15
- package/dist/decorators/collate.d.ts +16 -0
- package/dist/decorators/collate.js +16 -0
- package/dist/decorators/comment.d.ts +3 -1
- package/dist/decorators/comment.js +3 -1
- package/dist/decorators/database-settings.d.ts +6 -0
- package/dist/decorators/database-settings.js +6 -0
- package/dist/decorators/default.d.ts +2 -0
- package/dist/decorators/default.js +2 -0
- package/dist/decorators/encryption.d.ts +7 -1
- package/dist/decorators/encryption.js +7 -1
- package/dist/decorators/engine.d.ts +4 -0
- package/dist/decorators/engine.js +4 -0
- package/dist/decorators/fk-constraints.d.ts +32 -32
- package/dist/decorators/fk-constraints.js +32 -32
- package/dist/decorators/foreign-table.d.ts +1 -1
- package/dist/decorators/generated.d.ts +8 -0
- package/dist/decorators/generated.js +8 -0
- package/dist/decorators/hstore.d.ts +6 -0
- package/dist/decorators/hstore.js +6 -0
- package/dist/decorators/json-column.d.ts +2 -0
- package/dist/decorators/json-column.js +2 -0
- package/dist/decorators/jsonb.d.ts +6 -0
- package/dist/decorators/jsonb.js +6 -0
- package/dist/decorators/permissions.d.ts +12 -0
- package/dist/decorators/permissions.js +12 -0
- package/dist/decorators/procedure.d.ts +4 -2
- package/dist/decorators/procedure.js +4 -2
- package/dist/decorators/query-options.d.ts +24 -0
- package/dist/decorators/query-options.js +24 -0
- package/dist/decorators/range.d.ts +8 -0
- package/dist/decorators/range.js +8 -0
- package/dist/decorators/set-column.d.ts +2 -0
- package/dist/decorators/set-column.js +2 -0
- package/dist/decorators/spatial.d.ts +2 -0
- package/dist/decorators/spatial.js +2 -0
- package/dist/decorators/storage.d.ts +24 -0
- package/dist/decorators/storage.js +24 -0
- package/dist/decorators/timezone.d.ts +7 -7
- package/dist/decorators/timezone.js +7 -7
- package/dist/decorators/trigger.d.ts +3 -1
- package/dist/decorators/trigger.js +3 -1
- package/dist/decorators/uuid.d.ts +6 -0
- package/dist/decorators/uuid.js +6 -0
- package/dist/decorators/view.d.ts +7 -1
- package/dist/decorators/view.js +7 -1
- package/dist/dialects/dialect.d.ts +112 -0
- package/dist/external-fields/decorator.d.ts +2 -0
- package/dist/external-fields/decorator.js +2 -0
- package/dist/models/associations.d.ts +38 -0
- package/dist/models/associations.js +16 -0
- package/dist/models/decorators.d.ts +16 -16
- package/dist/models/decorators.js +21 -19
- package/dist/schema-objects.d.ts +42 -0
- package/dist/schema-objects.js +28 -0
- package/dist/types/index.d.ts +334 -0
- package/package.json +8 -4
package/dist/types/index.d.ts
CHANGED
|
@@ -520,6 +520,11 @@ export interface DropPolicyOptions {
|
|
|
520
520
|
/** Schema (for PostgreSQL) */
|
|
521
521
|
schema?: string;
|
|
522
522
|
}
|
|
523
|
+
/**
|
|
524
|
+
* Every SQL dialect prorm can target. The value chosen here decides which
|
|
525
|
+
* `Dialect` implementation compiles your `FindOptions` into SQL, so it governs
|
|
526
|
+
* identifier quoting, pagination syntax and which clauses are legal.
|
|
527
|
+
*/
|
|
523
528
|
export type Dialect = 'mysql' | 'postgres' | 'sqlite' | 'mssql' | 'mariadb' | 'oracle' | 'cockroachdb' | 'redshift' | 'db2' | 'snowflake' | 'clickhouse' | 'duckdb' | 'hana' | 'spanner' | 'turso' | 'tidb' | 'singlestore' | 'yugabytedb' | 'timescaledb' | 'greenplum' | 'vertica' | 'trino' | 'exasol' | 'questdb' | 'cratedb' | 'firebird' | 'databricks';
|
|
524
529
|
/**
|
|
525
530
|
* Query event data emitted when a query is executed
|
|
@@ -564,6 +569,11 @@ export interface PrormEvents {
|
|
|
564
569
|
/** Fired when there's an error */
|
|
565
570
|
error: (error: Error) => void;
|
|
566
571
|
}
|
|
572
|
+
/**
|
|
573
|
+
* Everything needed to construct a `Prorm` instance: which engine to
|
|
574
|
+
* talk to, how to reach it, and the cross-cutting behaviour (pooling, retries,
|
|
575
|
+
* logging, caching) that applies to every query it runs.
|
|
576
|
+
*/
|
|
567
577
|
export interface PrormOptions {
|
|
568
578
|
dialect: Dialect;
|
|
569
579
|
database?: string;
|
|
@@ -656,6 +666,11 @@ export interface SlowQueryEvent extends QueryEvent {
|
|
|
656
666
|
/** The threshold that was exceeded (in ms) */
|
|
657
667
|
threshold: number;
|
|
658
668
|
}
|
|
669
|
+
/**
|
|
670
|
+
* Connection-pool sizing and lifecycle. A pooled connection is shared, so
|
|
671
|
+
* session state set on one query is not guaranteed to be visible to the next —
|
|
672
|
+
* use `onConnect` for settings that must apply to every connection.
|
|
673
|
+
*/
|
|
659
674
|
export interface PoolOptions {
|
|
660
675
|
/** Maximum number of connections in the pool */
|
|
661
676
|
max?: number;
|
|
@@ -678,6 +693,11 @@ export interface PoolOptions {
|
|
|
678
693
|
/** Log pool operations (acquire, release, etc.) */
|
|
679
694
|
logPoolOperations?: boolean;
|
|
680
695
|
}
|
|
696
|
+
/**
|
|
697
|
+
* Automatic retry policy for transient connection failures. `match` decides
|
|
698
|
+
* which errors are considered transient; anything unmatched fails immediately
|
|
699
|
+
* rather than being retried.
|
|
700
|
+
*/
|
|
681
701
|
export interface RetryOptions {
|
|
682
702
|
/** Maximum number of retry attempts (default: 3) */
|
|
683
703
|
max?: number;
|
|
@@ -692,6 +712,10 @@ export interface RetryOptions {
|
|
|
692
712
|
/** Maximum backoff time in ms (default: 10000) */
|
|
693
713
|
backoffMax?: number;
|
|
694
714
|
}
|
|
715
|
+
/**
|
|
716
|
+
* Per-model configuration: the table it maps to, whether timestamps and soft
|
|
717
|
+
* deletes are managed, and how attribute names are converted to column names.
|
|
718
|
+
*/
|
|
695
719
|
export interface ModelOptions {
|
|
696
720
|
tableName?: string;
|
|
697
721
|
/** Schema to use for this model (PostgreSQL) or database (MySQL) */
|
|
@@ -768,12 +792,20 @@ export declare enum SortDirection {
|
|
|
768
792
|
ASC = "ASC",
|
|
769
793
|
DESC = "DESC"
|
|
770
794
|
}
|
|
795
|
+
/**
|
|
796
|
+
* One column within an index, with the per-column modifiers (sort direction,
|
|
797
|
+
* collation, prefix length) that the engine supports.
|
|
798
|
+
*/
|
|
771
799
|
export interface IndexField {
|
|
772
800
|
name: string;
|
|
773
801
|
length?: number;
|
|
774
802
|
order?: SortDirection | 'ASC' | 'DESC';
|
|
775
803
|
collate?: string;
|
|
776
804
|
}
|
|
805
|
+
/**
|
|
806
|
+
* An index to create alongside the table. `where` produces a partial index,
|
|
807
|
+
* which several engines do not support — see the indexes guide for the matrix.
|
|
808
|
+
*/
|
|
777
809
|
export interface IndexOptions {
|
|
778
810
|
name?: string;
|
|
779
811
|
/** Single field name or array of field names for composite indexes */
|
|
@@ -809,6 +841,10 @@ export interface IndexExpression {
|
|
|
809
841
|
/** Optional name for the expression */
|
|
810
842
|
name?: string;
|
|
811
843
|
}
|
|
844
|
+
/**
|
|
845
|
+
* A table constraint: primary key, unique, check, foreign key or exclusion.
|
|
846
|
+
* Composite constraints list every participating column in `fields`.
|
|
847
|
+
*/
|
|
812
848
|
export interface ConstraintOptions {
|
|
813
849
|
/** Custom constraint name (auto-generated if not provided) */
|
|
814
850
|
name?: string;
|
|
@@ -1021,6 +1057,10 @@ export interface InstanceValidateOptions {
|
|
|
1021
1057
|
/** Validate on update only (for instance validation) */
|
|
1022
1058
|
validateOnUpdate?: boolean;
|
|
1023
1059
|
}
|
|
1060
|
+
/**
|
|
1061
|
+
* A named, reusable fragment of `FindOptions` that a model can apply by name,
|
|
1062
|
+
* either always (the default scope) or on request.
|
|
1063
|
+
*/
|
|
1024
1064
|
export interface ScopeOptions {
|
|
1025
1065
|
attributes?: FindOptions['attributes'];
|
|
1026
1066
|
where?: WhereOptions;
|
|
@@ -1030,10 +1070,21 @@ export interface ScopeOptions {
|
|
|
1030
1070
|
offset?: number;
|
|
1031
1071
|
transaction?: Transaction;
|
|
1032
1072
|
}
|
|
1073
|
+
/**
|
|
1074
|
+
* Model-level validators, which run after per-attribute validation and can
|
|
1075
|
+
* therefore see the whole instance — the place for rules that span fields.
|
|
1076
|
+
*/
|
|
1033
1077
|
export interface ModelValidationOptions {
|
|
1034
1078
|
[key: string]: ValidationMethod | ValidationChain;
|
|
1035
1079
|
}
|
|
1080
|
+
/**
|
|
1081
|
+
* The name of a built-in validator, or a custom function.
|
|
1082
|
+
*/
|
|
1036
1083
|
export type ValidationMethod = (value: any) => boolean | string | Error;
|
|
1084
|
+
/**
|
|
1085
|
+
* An ordered list of validators applied to one attribute, evaluated until one
|
|
1086
|
+
* fails.
|
|
1087
|
+
*/
|
|
1037
1088
|
export interface ValidationChain {
|
|
1038
1089
|
is: [RegExp | string, string?];
|
|
1039
1090
|
not: [RegExp | string, string?];
|
|
@@ -1063,89 +1114,164 @@ export interface ValidationChain {
|
|
|
1063
1114
|
max: number;
|
|
1064
1115
|
min: number;
|
|
1065
1116
|
}
|
|
1117
|
+
/**
|
|
1118
|
+
* Any column type. The union covers the built-in `DataTypes` factories and the
|
|
1119
|
+
* dialect-specific types layered on top of them.
|
|
1120
|
+
*/
|
|
1066
1121
|
export type DataType = DataTypeString | DataTypeChar | DataTypeText | DataTypeNumber | DataTypeInteger | DataTypeBigInt | DataTypeFloat | DataTypeDouble | DataTypeDecimal | DataTypeBoolean | DataTypeDate | DataTypeDateOnly | DataTypeTime | DataTypeBlob | DataTypeEnum | DataTypeJSON | DataTypeJSONB | DataTypeUUID | DataTypeGeometry | DataTypeSET | DataTypeHStore | DataTypeRange | DataTypeInet | DataTypeCidr | DataTypeMacAddr | string;
|
|
1122
|
+
/**
|
|
1123
|
+
* The shape every data type shares: a `key` identifying it and a `toSql()`
|
|
1124
|
+
* that renders the engine-specific column type.
|
|
1125
|
+
*/
|
|
1067
1126
|
export interface DataTypeAbstract {
|
|
1068
1127
|
key: string;
|
|
1069
1128
|
toSql?: () => string;
|
|
1070
1129
|
}
|
|
1130
|
+
/**
|
|
1131
|
+
* Variable-length character data, `VARCHAR(n)` on most engines.
|
|
1132
|
+
*/
|
|
1071
1133
|
export interface DataTypeString extends DataTypeAbstract {
|
|
1072
1134
|
key: 'STRING';
|
|
1073
1135
|
length: number;
|
|
1074
1136
|
}
|
|
1137
|
+
/**
|
|
1138
|
+
* Fixed-length character data, `CHAR(n)`; shorter values are space-padded.
|
|
1139
|
+
*/
|
|
1075
1140
|
export interface DataTypeChar extends DataTypeAbstract {
|
|
1076
1141
|
key: 'CHAR';
|
|
1077
1142
|
length: number;
|
|
1078
1143
|
}
|
|
1144
|
+
/**
|
|
1145
|
+
* Unbounded character data. The size variants map to the engine's own
|
|
1146
|
+
* `TINYTEXT`/`MEDIUMTEXT`/`LONGTEXT` where those exist.
|
|
1147
|
+
*/
|
|
1079
1148
|
export interface DataTypeText extends DataTypeAbstract {
|
|
1080
1149
|
key: 'TEXT';
|
|
1081
1150
|
length?: number;
|
|
1082
1151
|
}
|
|
1152
|
+
/**
|
|
1153
|
+
* Shared options for the numeric types: precision, scale, sign and zero-fill.
|
|
1154
|
+
*/
|
|
1083
1155
|
export interface DataTypeNumber extends DataTypeAbstract {
|
|
1084
1156
|
key: 'NUMBER';
|
|
1085
1157
|
precision: number;
|
|
1086
1158
|
scale: number;
|
|
1087
1159
|
}
|
|
1160
|
+
/**
|
|
1161
|
+
* A 32-bit integer.
|
|
1162
|
+
*/
|
|
1088
1163
|
export interface DataTypeInteger extends DataTypeAbstract {
|
|
1089
1164
|
key: 'INTEGER';
|
|
1090
1165
|
length?: number;
|
|
1091
1166
|
unsigned?: boolean;
|
|
1092
1167
|
zerofill?: boolean;
|
|
1093
1168
|
}
|
|
1169
|
+
/**
|
|
1170
|
+
* A 64-bit integer. Values beyond `Number.MAX_SAFE_INTEGER` are returned as
|
|
1171
|
+
* strings by most drivers, so treat the result as a string when the range
|
|
1172
|
+
* matters.
|
|
1173
|
+
*/
|
|
1094
1174
|
export interface DataTypeBigInt extends DataTypeAbstract {
|
|
1095
1175
|
key: 'BIGINT';
|
|
1096
1176
|
length?: number;
|
|
1097
1177
|
unsigned?: boolean;
|
|
1098
1178
|
}
|
|
1179
|
+
/**
|
|
1180
|
+
* Single-precision floating point. Inexact — do not use for money.
|
|
1181
|
+
*/
|
|
1099
1182
|
export interface DataTypeFloat extends DataTypeAbstract {
|
|
1100
1183
|
key: 'FLOAT';
|
|
1101
1184
|
length?: number;
|
|
1102
1185
|
decimals?: number;
|
|
1103
1186
|
unsigned?: boolean;
|
|
1104
1187
|
}
|
|
1188
|
+
/**
|
|
1189
|
+
* Double-precision floating point. Inexact — do not use for money.
|
|
1190
|
+
*/
|
|
1105
1191
|
export interface DataTypeDouble extends DataTypeAbstract {
|
|
1106
1192
|
key: 'DOUBLE';
|
|
1107
1193
|
length?: number;
|
|
1108
1194
|
decimals?: number;
|
|
1109
1195
|
unsigned?: boolean;
|
|
1110
1196
|
}
|
|
1197
|
+
/**
|
|
1198
|
+
* Exact fixed-point numeric with the given precision and scale. The type to
|
|
1199
|
+
* use for money.
|
|
1200
|
+
*/
|
|
1111
1201
|
export interface DataTypeDecimal extends DataTypeAbstract {
|
|
1112
1202
|
key: 'DECIMAL';
|
|
1113
1203
|
precision: number;
|
|
1114
1204
|
scale: number;
|
|
1115
1205
|
unsigned?: boolean;
|
|
1116
1206
|
}
|
|
1207
|
+
/**
|
|
1208
|
+
* A boolean. Engines without a native boolean store it as a small integer or
|
|
1209
|
+
* a single character; the dialect handles the conversion.
|
|
1210
|
+
*/
|
|
1117
1211
|
export interface DataTypeBoolean extends DataTypeAbstract {
|
|
1118
1212
|
key: 'BOOLEAN';
|
|
1119
1213
|
}
|
|
1214
|
+
/**
|
|
1215
|
+
* A timestamp, with time zone where the engine supports one.
|
|
1216
|
+
*/
|
|
1120
1217
|
export interface DataTypeDate extends DataTypeAbstract {
|
|
1121
1218
|
key: 'DATE';
|
|
1122
1219
|
precision?: number;
|
|
1123
1220
|
timezone?: boolean;
|
|
1124
1221
|
}
|
|
1222
|
+
/**
|
|
1223
|
+
* A calendar date with no time component.
|
|
1224
|
+
*/
|
|
1125
1225
|
export interface DataTypeDateOnly extends DataTypeAbstract {
|
|
1126
1226
|
key: 'DATEONLY';
|
|
1127
1227
|
}
|
|
1228
|
+
/**
|
|
1229
|
+
* A time of day with no date component.
|
|
1230
|
+
*/
|
|
1128
1231
|
export interface DataTypeTime extends DataTypeAbstract {
|
|
1129
1232
|
key: 'TIME';
|
|
1130
1233
|
precision?: number;
|
|
1131
1234
|
}
|
|
1235
|
+
/**
|
|
1236
|
+
* Binary data. The size variants map to the engine's own blob types.
|
|
1237
|
+
*/
|
|
1132
1238
|
export interface DataTypeBlob extends DataTypeAbstract {
|
|
1133
1239
|
key: 'BLOB';
|
|
1134
1240
|
length?: 'tiny' | 'medium' | 'long';
|
|
1135
1241
|
}
|
|
1242
|
+
/**
|
|
1243
|
+
* A column restricted to a fixed set of string values. Engines without native
|
|
1244
|
+
* enums emit a check constraint instead.
|
|
1245
|
+
*/
|
|
1136
1246
|
export interface DataTypeEnum extends DataTypeAbstract {
|
|
1137
1247
|
key: 'ENUM';
|
|
1138
1248
|
values: string[];
|
|
1139
1249
|
}
|
|
1250
|
+
/**
|
|
1251
|
+
* A JSON document. Values round-trip as parsed JavaScript values on every
|
|
1252
|
+
* dialect — the write side encodes and the read side parses, so a string is
|
|
1253
|
+
* returned as the string it was stored as.
|
|
1254
|
+
*/
|
|
1140
1255
|
export interface DataTypeJSON extends DataTypeAbstract {
|
|
1141
1256
|
key: 'JSON';
|
|
1142
1257
|
}
|
|
1258
|
+
/**
|
|
1259
|
+
* PostgreSQL's binary JSON: indexable and faster to query than {@link
|
|
1260
|
+
* DataTypeJSON}, at the cost of not preserving key order or whitespace.
|
|
1261
|
+
*/
|
|
1143
1262
|
export interface DataTypeJSONB extends DataTypeAbstract {
|
|
1144
1263
|
key: 'JSONB';
|
|
1145
1264
|
}
|
|
1265
|
+
/**
|
|
1266
|
+
* A UUID, stored natively where the engine has the type and as a 36-character
|
|
1267
|
+
* string where it does not.
|
|
1268
|
+
*/
|
|
1146
1269
|
export interface DataTypeUUID extends DataTypeAbstract {
|
|
1147
1270
|
key: 'UUID';
|
|
1148
1271
|
}
|
|
1272
|
+
/**
|
|
1273
|
+
* A spatial value (point, polygon and so on), with an optional SRID.
|
|
1274
|
+
*/
|
|
1149
1275
|
export interface DataTypeGeometry extends DataTypeAbstract {
|
|
1150
1276
|
key: 'GEOMETRY';
|
|
1151
1277
|
type: string;
|
|
@@ -1175,6 +1301,10 @@ export interface SetColumnOptions {
|
|
|
1175
1301
|
/** Optional name for the SET type (useful for custom types) */
|
|
1176
1302
|
name?: string;
|
|
1177
1303
|
}
|
|
1304
|
+
/**
|
|
1305
|
+
* A computed attribute that exists on the instance but has no column. Declare
|
|
1306
|
+
* the fields it reads so a query that selects it also selects its inputs.
|
|
1307
|
+
*/
|
|
1178
1308
|
export interface DataTypeVirtual extends DataTypeAbstract {
|
|
1179
1309
|
key: 'VIRTUAL';
|
|
1180
1310
|
returnType?: DataType;
|
|
@@ -1223,6 +1353,10 @@ export interface DataTypeHStore extends DataTypeAbstract {
|
|
|
1223
1353
|
* - daterange: Range of date
|
|
1224
1354
|
*/
|
|
1225
1355
|
export type RangeSubtype = 'int4range' | 'int8range' | 'numrange' | 'tsrange' | 'tstzrange' | 'daterange';
|
|
1356
|
+
/**
|
|
1357
|
+
* A PostgreSQL range type over another type, such as `int4range` or
|
|
1358
|
+
* `tstzrange`.
|
|
1359
|
+
*/
|
|
1226
1360
|
export interface DataTypeRange extends DataTypeAbstract {
|
|
1227
1361
|
key: 'RANGE';
|
|
1228
1362
|
subtype: RangeSubtype;
|
|
@@ -1321,6 +1455,10 @@ export interface ArrayOperatorOptions {
|
|
|
1321
1455
|
/** Array ALL operator */
|
|
1322
1456
|
$arrayAll?: any;
|
|
1323
1457
|
}
|
|
1458
|
+
/**
|
|
1459
|
+
* One column of a model: its type, nullability, default, key membership and
|
|
1460
|
+
* the name it maps to in the database.
|
|
1461
|
+
*/
|
|
1324
1462
|
export interface AttributeOptions {
|
|
1325
1463
|
type: DataType;
|
|
1326
1464
|
allowNull?: boolean;
|
|
@@ -1352,6 +1490,10 @@ export interface AttributeOptions {
|
|
|
1352
1490
|
hidden?: boolean;
|
|
1353
1491
|
virtual?: boolean;
|
|
1354
1492
|
}
|
|
1493
|
+
/**
|
|
1494
|
+
* The target of a foreign key — which table and column it points at, and what
|
|
1495
|
+
* happens on update or delete.
|
|
1496
|
+
*/
|
|
1355
1497
|
export interface ReferenceOptions {
|
|
1356
1498
|
model: string | ModelStatic<any>;
|
|
1357
1499
|
key?: string;
|
|
@@ -1359,6 +1501,11 @@ export interface ReferenceOptions {
|
|
|
1359
1501
|
onDelete?: ReferentialAction | 'CASCADE' | 'RESTRICT' | 'SET NULL' | 'NO ACTION' | 'SET DEFAULT';
|
|
1360
1502
|
onUpdate?: ReferentialAction | 'CASCADE' | 'RESTRICT' | 'SET NULL' | 'NO ACTION' | 'SET DEFAULT';
|
|
1361
1503
|
}
|
|
1504
|
+
/**
|
|
1505
|
+
* The lifecycle callbacks a model can declare. `beforeSave`/`afterSave` wrap
|
|
1506
|
+
* both create and update, so shared logic belongs there rather than duplicated
|
|
1507
|
+
* across the pair.
|
|
1508
|
+
*/
|
|
1362
1509
|
export interface ModelHooks {
|
|
1363
1510
|
beforeValidate?: HookHandler;
|
|
1364
1511
|
afterValidate?: HookHandler;
|
|
@@ -1379,10 +1526,25 @@ export interface ModelHooks {
|
|
|
1379
1526
|
beforeFind?: FindHookHandler;
|
|
1380
1527
|
afterFind?: AfterFindHookHandler;
|
|
1381
1528
|
}
|
|
1529
|
+
/**
|
|
1530
|
+
* A hook that runs before a read, and may modify the options in place.
|
|
1531
|
+
*/
|
|
1382
1532
|
export type FindHookHandler = (options: FindOptions, model: ModelStatic<any>) => Promise<void> | void;
|
|
1533
|
+
/**
|
|
1534
|
+
* A hook that runs after a read, receiving the instances it produced.
|
|
1535
|
+
*/
|
|
1383
1536
|
export type AfterFindHookHandler = (instances: Model[], options: FindOptions, model: ModelStatic<any>) => Promise<void> | void;
|
|
1537
|
+
/**
|
|
1538
|
+
* A hook receiving a single instance and the options for the operation.
|
|
1539
|
+
*/
|
|
1384
1540
|
export type HookHandler = (instance: Model, options?: HookOptions) => Promise<void> | void;
|
|
1541
|
+
/**
|
|
1542
|
+
* A hook receiving every instance in a bulk operation at once.
|
|
1543
|
+
*/
|
|
1385
1544
|
export type BulkHookHandler = (instances?: Model[], options?: HookOptions) => Promise<void> | void;
|
|
1545
|
+
/**
|
|
1546
|
+
* Controls whether hooks run for an operation, and which ones.
|
|
1547
|
+
*/
|
|
1386
1548
|
export interface HookOptions {
|
|
1387
1549
|
transaction?: Transaction;
|
|
1388
1550
|
hooks?: boolean;
|
|
@@ -1394,9 +1556,16 @@ export interface HookOptions {
|
|
|
1394
1556
|
model?: any;
|
|
1395
1557
|
instances?: Model[];
|
|
1396
1558
|
}
|
|
1559
|
+
/**
|
|
1560
|
+
* A `WHERE` clause: attribute/value pairs, operator objects, or nested
|
|
1561
|
+
* `and`/`or`/`not` groups.
|
|
1562
|
+
*/
|
|
1397
1563
|
export type WhereOptions<T = any> = {
|
|
1398
1564
|
[key: string]: any;
|
|
1399
1565
|
} | WhereLogical<T>;
|
|
1566
|
+
/**
|
|
1567
|
+
* The logical combinators available inside a `WHERE` clause.
|
|
1568
|
+
*/
|
|
1400
1569
|
export interface WhereLogical<T> {
|
|
1401
1570
|
$and?: WhereOptions<T>[];
|
|
1402
1571
|
$or?: WhereOptions<T>[];
|
|
@@ -1468,6 +1637,10 @@ export interface SubqueryOptions {
|
|
|
1468
1637
|
export type HavingOptions<T = any> = {
|
|
1469
1638
|
[key: string]: any;
|
|
1470
1639
|
} | HavingLogical<T>;
|
|
1640
|
+
/**
|
|
1641
|
+
* The logical combinators available inside a `HAVING` clause, applied after
|
|
1642
|
+
* grouping rather than before it.
|
|
1643
|
+
*/
|
|
1471
1644
|
export interface HavingLogical<T> {
|
|
1472
1645
|
$and?: HavingOptions<T>[];
|
|
1473
1646
|
$or?: HavingOptions<T>[];
|
|
@@ -1482,6 +1655,9 @@ export interface HavingLogical<T> {
|
|
|
1482
1655
|
* - Literal SQL with alias: [['COUNT(*)', 'count']]
|
|
1483
1656
|
*/
|
|
1484
1657
|
export type AttributeValue = string | [any, string] | [any, any, string];
|
|
1658
|
+
/**
|
|
1659
|
+
* Which columns to select — a list, or an include/exclude pair.
|
|
1660
|
+
*/
|
|
1485
1661
|
export type AttributesOptions = string[] | {
|
|
1486
1662
|
include?: string[];
|
|
1487
1663
|
exclude?: string[];
|
|
@@ -1533,6 +1709,11 @@ export interface UnpivotOptions {
|
|
|
1533
1709
|
/** Name for the column name column in the result */
|
|
1534
1710
|
nameColumn: string;
|
|
1535
1711
|
}
|
|
1712
|
+
/**
|
|
1713
|
+
* The single options object every finder compiles into SQL. `where`,
|
|
1714
|
+
* `include`, `order`, `limit`, locking and the rest behave identically
|
|
1715
|
+
* whichever finder you call.
|
|
1716
|
+
*/
|
|
1536
1717
|
export interface FindOptions {
|
|
1537
1718
|
where?: WhereOptions;
|
|
1538
1719
|
attributes?: AttributesOptions;
|
|
@@ -1734,6 +1915,10 @@ export interface FindOptions {
|
|
|
1734
1915
|
*/
|
|
1735
1916
|
streamHighWatermark?: number;
|
|
1736
1917
|
}
|
|
1918
|
+
/**
|
|
1919
|
+
* Options for `findOrCreate`: the search criteria plus the `defaults` used
|
|
1920
|
+
* only when nothing matched.
|
|
1921
|
+
*/
|
|
1737
1922
|
export interface FindOrCreateOptions<T = any> extends FindOptions {
|
|
1738
1923
|
/** Default values to use when creating a new record if not found */
|
|
1739
1924
|
defaults?: Partial<T>;
|
|
@@ -1742,6 +1927,10 @@ export interface FindOrCreateOptions<T = any> extends FindOptions {
|
|
|
1742
1927
|
/** Whether to validate the model before creation (default: true) */
|
|
1743
1928
|
validate?: boolean;
|
|
1744
1929
|
}
|
|
1930
|
+
/**
|
|
1931
|
+
* An `ORDER BY` clause. Use the array-of-arrays form — a bare string is not
|
|
1932
|
+
* parsed into column and direction.
|
|
1933
|
+
*/
|
|
1745
1934
|
export type Order = OrderItem[] | string | [string, string][] | import('../operators').OrderExpression[];
|
|
1746
1935
|
/**
|
|
1747
1936
|
* Options for JSON path extraction
|
|
@@ -1854,6 +2043,9 @@ export interface DWithinOptions {
|
|
|
1854
2043
|
* GROUP BY clause format
|
|
1855
2044
|
*/
|
|
1856
2045
|
export type GroupBy = string | string[] | GroupByItem[];
|
|
2046
|
+
/**
|
|
2047
|
+
* One `GROUP BY` term: a column, a literal, or a function call.
|
|
2048
|
+
*/
|
|
1857
2049
|
export interface GroupByItem {
|
|
1858
2050
|
model?: ModelStatic<any>;
|
|
1859
2051
|
as?: string;
|
|
@@ -1929,6 +2121,10 @@ export interface NowaitOptions {
|
|
|
1929
2121
|
export interface SkipLockedOptions {
|
|
1930
2122
|
skipLocked: true;
|
|
1931
2123
|
}
|
|
2124
|
+
/**
|
|
2125
|
+
* An association to eager-load, given as the model, its alias, or a full
|
|
2126
|
+
* {@link IncludeOptions}.
|
|
2127
|
+
*/
|
|
1932
2128
|
export interface Includeable {
|
|
1933
2129
|
/** The model to include */
|
|
1934
2130
|
model: ModelStatic<any>;
|
|
@@ -1954,6 +2150,10 @@ export interface Includeable {
|
|
|
1954
2150
|
*/
|
|
1955
2151
|
as?: string;
|
|
1956
2152
|
}
|
|
2153
|
+
/**
|
|
2154
|
+
* A single eager-loaded association: which one, what to select from it,
|
|
2155
|
+
* whether it filters the parent (`required`), and any nesting beneath it.
|
|
2156
|
+
*/
|
|
1957
2157
|
export interface IncludeOptions extends Includeable {
|
|
1958
2158
|
where?: WhereOptions;
|
|
1959
2159
|
attributes?: string[] | {
|
|
@@ -2136,6 +2336,10 @@ export interface AntiJoinOptions {
|
|
|
2136
2336
|
*/
|
|
2137
2337
|
type?: 'notExists' | 'notIn' | 'leftJoinIsNull';
|
|
2138
2338
|
}
|
|
2339
|
+
/**
|
|
2340
|
+
* Options for inserting one row: which fields to write, whether to validate,
|
|
2341
|
+
* and the transaction to run inside.
|
|
2342
|
+
*/
|
|
2139
2343
|
export interface CreateOptions extends SaveOptions {
|
|
2140
2344
|
include?: Includeable[] | IncludeOptions[];
|
|
2141
2345
|
ignoreDuplicates?: boolean;
|
|
@@ -2150,6 +2354,10 @@ export interface CreateOptions extends SaveOptions {
|
|
|
2150
2354
|
*/
|
|
2151
2355
|
using?: string;
|
|
2152
2356
|
}
|
|
2357
|
+
/**
|
|
2358
|
+
* Options for updating rows: the `where` that selects them, which fields may
|
|
2359
|
+
* be written, and whether hooks run per row.
|
|
2360
|
+
*/
|
|
2153
2361
|
export interface UpdateOptions extends SaveOptions {
|
|
2154
2362
|
where: WhereOptions;
|
|
2155
2363
|
limit?: number;
|
|
@@ -2168,6 +2376,10 @@ export interface UpdateOptions extends SaveOptions {
|
|
|
2168
2376
|
*/
|
|
2169
2377
|
using?: string;
|
|
2170
2378
|
}
|
|
2379
|
+
/**
|
|
2380
|
+
* Options for deleting rows. On a paranoid model this soft-deletes unless
|
|
2381
|
+
* `force` is set.
|
|
2382
|
+
*/
|
|
2171
2383
|
export interface DestroyOptions extends HookOptions {
|
|
2172
2384
|
where: WhereOptions;
|
|
2173
2385
|
limit?: number;
|
|
@@ -2190,6 +2402,9 @@ export interface DestroyOptions extends HookOptions {
|
|
|
2190
2402
|
*/
|
|
2191
2403
|
using?: string;
|
|
2192
2404
|
}
|
|
2405
|
+
/**
|
|
2406
|
+
* Options for persisting an instance, whether that is an insert or an update.
|
|
2407
|
+
*/
|
|
2193
2408
|
export interface SaveOptions {
|
|
2194
2409
|
transaction?: Transaction;
|
|
2195
2410
|
hooks?: boolean;
|
|
@@ -2199,6 +2414,9 @@ export interface SaveOptions {
|
|
|
2199
2414
|
logging?: boolean | ((sql: string, time?: number) => void);
|
|
2200
2415
|
benchmark?: boolean;
|
|
2201
2416
|
}
|
|
2417
|
+
/**
|
|
2418
|
+
* Options for refetching an instance's current database state.
|
|
2419
|
+
*/
|
|
2202
2420
|
export interface ReloadOptions extends FindOptions {
|
|
2203
2421
|
/**
|
|
2204
2422
|
* Specify attributes to select when reloading from the database.
|
|
@@ -2210,6 +2428,10 @@ export interface ReloadOptions extends FindOptions {
|
|
|
2210
2428
|
*/
|
|
2211
2429
|
hooks?: boolean;
|
|
2212
2430
|
}
|
|
2431
|
+
/**
|
|
2432
|
+
* Shared options for every association: the alias it is exposed under, the
|
|
2433
|
+
* foreign key, and what happens to children when the parent goes.
|
|
2434
|
+
*/
|
|
2213
2435
|
export interface AssociationOptions {
|
|
2214
2436
|
as?: string;
|
|
2215
2437
|
/**
|
|
@@ -2253,6 +2475,10 @@ export interface AssociationOptions {
|
|
|
2253
2475
|
through?: string | ThroughOptions;
|
|
2254
2476
|
scope?: AssociationScope;
|
|
2255
2477
|
}
|
|
2478
|
+
/**
|
|
2479
|
+
* Foreign-key specifics for an association, when the defaults derived from
|
|
2480
|
+
* the model names are not what you want.
|
|
2481
|
+
*/
|
|
2256
2482
|
export interface AssociationForeignKeyOptions {
|
|
2257
2483
|
/** Custom name for the foreign key constraint */
|
|
2258
2484
|
name?: string;
|
|
@@ -2270,6 +2496,10 @@ export interface AssociationForeignKeyOptions {
|
|
|
2270
2496
|
/** Custom constraint name for the foreign key (alternative to 'name') */
|
|
2271
2497
|
constraintName?: string;
|
|
2272
2498
|
}
|
|
2499
|
+
/**
|
|
2500
|
+
* The join table of a many-to-many association, and any extra attributes
|
|
2501
|
+
* carried on it.
|
|
2502
|
+
*/
|
|
2273
2503
|
export interface ThroughOptions {
|
|
2274
2504
|
model: string | ModelStatic<any>;
|
|
2275
2505
|
as?: string;
|
|
@@ -2278,6 +2508,10 @@ export interface ThroughOptions {
|
|
|
2278
2508
|
scope?: AssociationScope;
|
|
2279
2509
|
timestamps?: boolean;
|
|
2280
2510
|
}
|
|
2511
|
+
/**
|
|
2512
|
+
* A filter applied to every query through an association — the mechanism
|
|
2513
|
+
* behind polymorphic associations.
|
|
2514
|
+
*/
|
|
2281
2515
|
export interface AssociationScope {
|
|
2282
2516
|
[key: string]: any;
|
|
2283
2517
|
}
|
|
@@ -2294,6 +2528,10 @@ export declare class Transaction {
|
|
|
2294
2528
|
commit(): Promise<void>;
|
|
2295
2529
|
rollback(): Promise<void>;
|
|
2296
2530
|
}
|
|
2531
|
+
/**
|
|
2532
|
+
* Options for a transaction: isolation level, type, and whether it nests as a
|
|
2533
|
+
* savepoint inside an outer transaction.
|
|
2534
|
+
*/
|
|
2297
2535
|
export interface TransactionOptions {
|
|
2298
2536
|
autocommit?: boolean;
|
|
2299
2537
|
/**
|
|
@@ -2347,6 +2585,10 @@ export declare enum IsolationLevel {
|
|
|
2347
2585
|
RepeatableRead = "REPEATABLE READ",
|
|
2348
2586
|
Serializable = "SERIALIZABLE"
|
|
2349
2587
|
}
|
|
2588
|
+
/**
|
|
2589
|
+
* The static side of a model class — the finders, writers and association
|
|
2590
|
+
* declarations, as opposed to an instance of it.
|
|
2591
|
+
*/
|
|
2350
2592
|
export interface ModelStatic<T extends Model> {
|
|
2351
2593
|
name: string;
|
|
2352
2594
|
tableName: string;
|
|
@@ -2742,6 +2984,10 @@ export interface ToJSONOptions {
|
|
|
2742
2984
|
*/
|
|
2743
2985
|
clone?: boolean;
|
|
2744
2986
|
}
|
|
2987
|
+
/**
|
|
2988
|
+
* The instance side of a model: the attribute accessors plus `save`,
|
|
2989
|
+
* `update`, `destroy`, `reload` and the association helpers.
|
|
2990
|
+
*/
|
|
2745
2991
|
export interface Model {
|
|
2746
2992
|
getDataValue(key: string): any;
|
|
2747
2993
|
setDataValue(key: string, value: any): void;
|
|
@@ -2765,6 +3011,10 @@ export interface Model {
|
|
|
2765
3011
|
reload(options?: FindOptions): Promise<this>;
|
|
2766
3012
|
toJSON(options?: ToJSONOptions): Record<string, any>;
|
|
2767
3013
|
}
|
|
3014
|
+
/**
|
|
3015
|
+
* A declared relationship between two models, and the metadata the query
|
|
3016
|
+
* builder needs to join them.
|
|
3017
|
+
*/
|
|
2768
3018
|
export interface Association {
|
|
2769
3019
|
source: ModelStatic<any>;
|
|
2770
3020
|
target: ModelStatic<any>;
|
|
@@ -2775,6 +3025,10 @@ export interface Association {
|
|
|
2775
3025
|
targetKey?: string | string[];
|
|
2776
3026
|
sourceKey?: string | string[];
|
|
2777
3027
|
}
|
|
3028
|
+
/**
|
|
3029
|
+
* Options for inserting many rows in one statement, including upsert
|
|
3030
|
+
* behaviour and whether each row is validated.
|
|
3031
|
+
*/
|
|
2778
3032
|
export interface BulkCreateOptions extends CreateOptions {
|
|
2779
3033
|
ignoreDuplicates?: boolean;
|
|
2780
3034
|
validate?: boolean;
|
|
@@ -2789,10 +3043,17 @@ export interface BulkCreateOptions extends CreateOptions {
|
|
|
2789
3043
|
/** Fields to update on conflict in upsert */
|
|
2790
3044
|
updateOnDuplicate?: string[];
|
|
2791
3045
|
}
|
|
3046
|
+
/**
|
|
3047
|
+
* Options for `count`, including `distinct` and the `where`/`include` that
|
|
3048
|
+
* narrow what is counted.
|
|
3049
|
+
*/
|
|
2792
3050
|
export interface CountOptions extends FindOptions {
|
|
2793
3051
|
distinct?: boolean;
|
|
2794
3052
|
col?: string;
|
|
2795
3053
|
}
|
|
3054
|
+
/**
|
|
3055
|
+
* Options for `sum`, `min`, `max` and friends.
|
|
3056
|
+
*/
|
|
2796
3057
|
export interface AggregateOptions extends FindOptions {
|
|
2797
3058
|
plain?: boolean;
|
|
2798
3059
|
}
|
|
@@ -2824,6 +3085,10 @@ export interface WindowFunctionOptions {
|
|
|
2824
3085
|
/** Default value for LAG/LEAD functions when the offset goes beyond the partition */
|
|
2825
3086
|
defaultValue?: any;
|
|
2826
3087
|
}
|
|
3088
|
+
/**
|
|
3089
|
+
* Options for an insert-or-update, including which columns decide whether a
|
|
3090
|
+
* row already exists.
|
|
3091
|
+
*/
|
|
2827
3092
|
export interface UpsertOptions extends Omit<UpdateOptions, 'where'>, CreateOptions {
|
|
2828
3093
|
/** Fields to use for conflict resolution (ON CONFLICT for PostgreSQL/SQLite, ON DUPLICATE KEY for MySQL) */
|
|
2829
3094
|
conflictFields?: string[];
|
|
@@ -2846,22 +3111,38 @@ export interface UpsertOptions extends Omit<UpdateOptions, 'where'>, CreateOptio
|
|
|
2846
3111
|
/** Whether to use paranoid mode when fetching the instance after upsert */
|
|
2847
3112
|
paranoid?: boolean;
|
|
2848
3113
|
}
|
|
3114
|
+
/**
|
|
3115
|
+
* Options for emptying a table, including whether to cascade to dependents
|
|
3116
|
+
* and restart identity sequences.
|
|
3117
|
+
*/
|
|
2849
3118
|
export interface TruncateOptions extends HookOptions {
|
|
2850
3119
|
cascade?: boolean;
|
|
2851
3120
|
restartIdentity?: boolean;
|
|
2852
3121
|
}
|
|
3122
|
+
/**
|
|
3123
|
+
* Options for dropping a table.
|
|
3124
|
+
*/
|
|
2853
3125
|
export interface DropOptions extends HookOptions {
|
|
2854
3126
|
cascade?: boolean;
|
|
2855
3127
|
}
|
|
3128
|
+
/**
|
|
3129
|
+
* Which validations to run, and whether to stop at the first failure.
|
|
3130
|
+
*/
|
|
2856
3131
|
export interface ValidationOptions {
|
|
2857
3132
|
fields?: string[];
|
|
2858
3133
|
validate?: boolean;
|
|
2859
3134
|
hooks?: boolean;
|
|
2860
3135
|
}
|
|
3136
|
+
/**
|
|
3137
|
+
* Options for undoing a soft delete on a paranoid model.
|
|
3138
|
+
*/
|
|
2861
3139
|
export interface RestoreOptions extends HookOptions {
|
|
2862
3140
|
where?: WhereOptions;
|
|
2863
3141
|
limit?: number;
|
|
2864
3142
|
}
|
|
3143
|
+
/**
|
|
3144
|
+
* Shared options for atomic increment and decrement.
|
|
3145
|
+
*/
|
|
2865
3146
|
export interface IncrementDecrementOptions extends HookOptions {
|
|
2866
3147
|
/** Amount to increment/decrement by (default: 1) */
|
|
2867
3148
|
by?: number;
|
|
@@ -2870,21 +3151,39 @@ export interface IncrementDecrementOptions extends HookOptions {
|
|
|
2870
3151
|
/** Whether to reload the instance after the operation (default: true) */
|
|
2871
3152
|
reload?: boolean;
|
|
2872
3153
|
}
|
|
3154
|
+
/**
|
|
3155
|
+
* Options for atomically adding to numeric columns, done in SQL so concurrent
|
|
3156
|
+
* writers do not lose updates.
|
|
3157
|
+
*/
|
|
2873
3158
|
export interface IncrementOptions extends IncrementDecrementOptions {
|
|
2874
3159
|
}
|
|
3160
|
+
/**
|
|
3161
|
+
* Options for atomically subtracting from numeric columns.
|
|
3162
|
+
*/
|
|
2875
3163
|
export interface DecrementOptions extends IncrementDecrementOptions {
|
|
2876
3164
|
}
|
|
3165
|
+
/**
|
|
3166
|
+
* Raised when one or more validators reject an instance; `errors` holds one
|
|
3167
|
+
* entry per failure.
|
|
3168
|
+
*/
|
|
2877
3169
|
export interface ValidationError extends Error {
|
|
2878
3170
|
name: string;
|
|
2879
3171
|
message: string;
|
|
2880
3172
|
errors: ValidationErrorItem[];
|
|
2881
3173
|
}
|
|
3174
|
+
/**
|
|
3175
|
+
* A single validation failure: which attribute, which validator, and the
|
|
3176
|
+
* message it produced.
|
|
3177
|
+
*/
|
|
2882
3178
|
export interface ValidationErrorItem {
|
|
2883
3179
|
message: string;
|
|
2884
3180
|
type: string;
|
|
2885
3181
|
path: string;
|
|
2886
3182
|
value: any;
|
|
2887
3183
|
}
|
|
3184
|
+
/**
|
|
3185
|
+
* The rows and metadata returned by a query.
|
|
3186
|
+
*/
|
|
2888
3187
|
export interface QueryResult {
|
|
2889
3188
|
rows: any[];
|
|
2890
3189
|
rowCount: number;
|
|
@@ -2904,6 +3203,9 @@ export interface QueryResult {
|
|
|
2904
3203
|
*/
|
|
2905
3204
|
resultSets?: any[][];
|
|
2906
3205
|
}
|
|
3206
|
+
/**
|
|
3207
|
+
* Column metadata a driver reports for a result set.
|
|
3208
|
+
*/
|
|
2907
3209
|
export interface FieldInfo {
|
|
2908
3210
|
name: string;
|
|
2909
3211
|
type: string;
|
|
@@ -2914,6 +3216,10 @@ export interface FieldInfo {
|
|
|
2914
3216
|
isEnum: boolean;
|
|
2915
3217
|
isPrimaryKey: boolean;
|
|
2916
3218
|
}
|
|
3219
|
+
/**
|
|
3220
|
+
* The result of `query()`, whose shape depends on the statement and the
|
|
3221
|
+
* `type` given in {@link QueryOptions}.
|
|
3222
|
+
*/
|
|
2917
3223
|
export interface RawQueryResult {
|
|
2918
3224
|
rows: any[];
|
|
2919
3225
|
count: number;
|
|
@@ -2927,6 +3233,10 @@ export interface RawQueryResult {
|
|
|
2927
3233
|
*/
|
|
2928
3234
|
import { QueryTypes } from './query-types';
|
|
2929
3235
|
export { QueryTypes };
|
|
3236
|
+
/**
|
|
3237
|
+
* Options for a raw query: how to interpret the result, what to bind, and
|
|
3238
|
+
* whether to map rows onto a model.
|
|
3239
|
+
*/
|
|
2930
3240
|
export interface QueryOptions {
|
|
2931
3241
|
plain?: boolean;
|
|
2932
3242
|
raw?: boolean;
|
|
@@ -3004,12 +3314,20 @@ export interface StreamOptions {
|
|
|
3004
3314
|
*/
|
|
3005
3315
|
logging?: boolean | ((sql: string, time?: number) => void);
|
|
3006
3316
|
}
|
|
3317
|
+
/**
|
|
3318
|
+
* Raised when the database rejects a statement; carries the driver's own
|
|
3319
|
+
* error alongside the SQL that produced it.
|
|
3320
|
+
*/
|
|
3007
3321
|
export interface QueryError extends Error {
|
|
3008
3322
|
parent?: Error;
|
|
3009
3323
|
original?: Error;
|
|
3010
3324
|
sql?: string;
|
|
3011
3325
|
parameters?: any[];
|
|
3012
3326
|
}
|
|
3327
|
+
/**
|
|
3328
|
+
* Options for `sync()`. `force` drops and recreates; `alter` tries to migrate
|
|
3329
|
+
* an existing table in place.
|
|
3330
|
+
*/
|
|
3013
3331
|
export interface SyncOptions {
|
|
3014
3332
|
/**
|
|
3015
3333
|
* If true, drop all tables first before recreating them.
|
|
@@ -3132,16 +3450,28 @@ export interface ReplicationOptions {
|
|
|
3132
3450
|
/** Whether to automatically fail over to master on all replicas unhealthy */
|
|
3133
3451
|
autoFailover?: boolean;
|
|
3134
3452
|
}
|
|
3453
|
+
/**
|
|
3454
|
+
* A row materialised as an object, with its attributes and instance methods.
|
|
3455
|
+
*/
|
|
3135
3456
|
export type ModelInstance<T = any> = any;
|
|
3457
|
+
/**
|
|
3458
|
+
* One node of a Redis cluster used as a cache backend.
|
|
3459
|
+
*/
|
|
3136
3460
|
export interface RedisClusterNode {
|
|
3137
3461
|
host: string;
|
|
3138
3462
|
port: number;
|
|
3139
3463
|
tls?: boolean;
|
|
3140
3464
|
}
|
|
3465
|
+
/**
|
|
3466
|
+
* The in-process first-level cache that sits in front of a shared cache.
|
|
3467
|
+
*/
|
|
3141
3468
|
export interface L1CacheOptions {
|
|
3142
3469
|
maxItems: number;
|
|
3143
3470
|
ttl: number;
|
|
3144
3471
|
}
|
|
3472
|
+
/**
|
|
3473
|
+
* Configuration for using a Redis cluster as the shared cache.
|
|
3474
|
+
*/
|
|
3145
3475
|
export interface RedisClusterCacheOptions {
|
|
3146
3476
|
nodes: RedisClusterNode[];
|
|
3147
3477
|
maxRedirects?: number;
|
|
@@ -3152,6 +3482,10 @@ export interface RedisClusterCacheOptions {
|
|
|
3152
3482
|
lazyConnect?: boolean;
|
|
3153
3483
|
l1?: L1CacheOptions;
|
|
3154
3484
|
}
|
|
3485
|
+
/**
|
|
3486
|
+
* How query results are cached: which backend, for how long, and how entries
|
|
3487
|
+
* are invalidated when a write touches the same table.
|
|
3488
|
+
*/
|
|
3155
3489
|
export interface CacheManagerOptions {
|
|
3156
3490
|
keyPrefix?: string;
|
|
3157
3491
|
defaultTtl?: number;
|