hysteria-orm 10.0.3 → 10.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cli.cjs +8 -8
- package/lib/cli.cjs.map +1 -1
- package/lib/cli.js +8 -8
- package/lib/cli.js.map +1 -1
- package/lib/index.cjs +12 -12
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +154 -48
- package/lib/index.d.ts +154 -48
- package/lib/index.js +12 -12
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/index.d.cts
CHANGED
|
@@ -65,7 +65,7 @@ type ModelKeyOrAnySort<T> = {
|
|
|
65
65
|
};
|
|
66
66
|
|
|
67
67
|
type FetchHooks$1 = "beforeFetch" | "afterFetch";
|
|
68
|
-
type BinaryOperatorType$2 = "$eq" | "$ne" | "$gt" | "$gte" | "$lt" | "$lte";
|
|
68
|
+
type BinaryOperatorType$2 = "$eq" | "$ne" | "$gt" | "$gte" | "$lt" | "$lte" | "$in" | "$nin";
|
|
69
69
|
type BaseValues$2 = string | number | boolean | Date | Array<string | number | boolean | Date>;
|
|
70
70
|
type OneOptions$1 = {
|
|
71
71
|
throwErrorOnNull?: boolean;
|
|
@@ -1360,16 +1360,33 @@ declare class Schema {
|
|
|
1360
1360
|
private generateAstInstance;
|
|
1361
1361
|
}
|
|
1362
1362
|
|
|
1363
|
+
declare class FromNode extends QueryNode {
|
|
1364
|
+
table: string | QueryNode | QueryNode[];
|
|
1365
|
+
chainsWith: string;
|
|
1366
|
+
canKeywordBeSeenMultipleTimes: boolean;
|
|
1367
|
+
folder: string;
|
|
1368
|
+
file: string;
|
|
1369
|
+
alias?: string;
|
|
1370
|
+
constructor(table: string | QueryNode | QueryNode[], alias?: string);
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1363
1373
|
declare class InterpreterUtils {
|
|
1364
1374
|
private readonly model;
|
|
1365
1375
|
private readonly modelColumnsMap;
|
|
1366
1376
|
constructor(model: typeof Model);
|
|
1367
1377
|
formatStringColumn(dbType: SqlDataSourceType, column: string): string;
|
|
1378
|
+
/**
|
|
1379
|
+
* @description Formats the table name for the database type, idempotent for quoting
|
|
1380
|
+
*/
|
|
1368
1381
|
formatStringTable(dbType: SqlDataSourceType, table: string): string;
|
|
1369
1382
|
prepareColumns(columns: string[], values: any[], mode?: "insert" | "update"): {
|
|
1370
1383
|
columns: string[];
|
|
1371
1384
|
values: any[];
|
|
1372
1385
|
};
|
|
1386
|
+
/**
|
|
1387
|
+
* @description Formats the from node for write operations removing the "from" keyword
|
|
1388
|
+
*/
|
|
1389
|
+
getFromForWriteOperations(dbType: SqlDataSourceType, fromNode: FromNode): string;
|
|
1373
1390
|
}
|
|
1374
1391
|
|
|
1375
1392
|
type BaseValues$1 = string | number | boolean | undefined | null | RawNode;
|
|
@@ -1504,16 +1521,6 @@ declare class DistinctOnNode extends QueryNode {
|
|
|
1504
1521
|
constructor(columns: string[]);
|
|
1505
1522
|
}
|
|
1506
1523
|
|
|
1507
|
-
declare class FromNode extends QueryNode {
|
|
1508
|
-
table: string | QueryNode | QueryNode[];
|
|
1509
|
-
chainsWith: string;
|
|
1510
|
-
canKeywordBeSeenMultipleTimes: boolean;
|
|
1511
|
-
folder: string;
|
|
1512
|
-
file: string;
|
|
1513
|
-
alias?: string;
|
|
1514
|
-
constructor(table: string | QueryNode | QueryNode[], alias?: string);
|
|
1515
|
-
}
|
|
1516
|
-
|
|
1517
1524
|
declare class SelectNode extends QueryNode {
|
|
1518
1525
|
column: string | QueryNode | QueryNode[];
|
|
1519
1526
|
alias?: string;
|
|
@@ -2556,6 +2563,27 @@ type BaseModelMethodOptions = {
|
|
|
2556
2563
|
*/
|
|
2557
2564
|
ignoreHooks?: boolean;
|
|
2558
2565
|
};
|
|
2566
|
+
/**
|
|
2567
|
+
* @description Options that can be provided to a raw sql operation (like the raw QueryBuilder)
|
|
2568
|
+
*/
|
|
2569
|
+
type RawModelOptions = {
|
|
2570
|
+
/**
|
|
2571
|
+
* Alias for the table
|
|
2572
|
+
*/
|
|
2573
|
+
alias?: string;
|
|
2574
|
+
/**
|
|
2575
|
+
* @description Convert the column casing before making a Database query, by default preserves what is provided
|
|
2576
|
+
*/
|
|
2577
|
+
databaseCaseConvention?: CaseConvention;
|
|
2578
|
+
/**
|
|
2579
|
+
* Column to use for soft deleted, by default is `deleted_at`
|
|
2580
|
+
*/
|
|
2581
|
+
softDeleteColumn?: string;
|
|
2582
|
+
/**
|
|
2583
|
+
* Column to use for soft deleted, by default is date in format: "YYYY-MM-DD HH:mm:ss" in UTC timezone
|
|
2584
|
+
*/
|
|
2585
|
+
softDeleteValue?: string | boolean;
|
|
2586
|
+
};
|
|
2559
2587
|
|
|
2560
2588
|
/**
|
|
2561
2589
|
* @description Due to query limitations some query builder methods may not be available in a RelationQueryBuilder
|
|
@@ -2606,6 +2634,30 @@ declare class ModelQueryBuilder<T extends Model, A extends Record<string, any> =
|
|
|
2606
2634
|
data: [CursorPaginatedData<T, A, R>, Cursor<T, ModelKey<T>>];
|
|
2607
2635
|
time: number;
|
|
2608
2636
|
}>;
|
|
2637
|
+
truncate: (returnType?: "millis" | "seconds") => Promise<{
|
|
2638
|
+
data: void;
|
|
2639
|
+
time: number;
|
|
2640
|
+
}>;
|
|
2641
|
+
delete: (returnType?: "millis" | "seconds") => Promise<{
|
|
2642
|
+
data: number;
|
|
2643
|
+
time: number;
|
|
2644
|
+
}>;
|
|
2645
|
+
insert: (data: Partial<ModelWithoutRelations<T>>, returnType?: "millis" | "seconds") => Promise<{
|
|
2646
|
+
data: T;
|
|
2647
|
+
time: number;
|
|
2648
|
+
}>;
|
|
2649
|
+
insertMany: (data: Partial<ModelWithoutRelations<T>>[], returnType?: "millis" | "seconds") => Promise<{
|
|
2650
|
+
data: T[];
|
|
2651
|
+
time: number;
|
|
2652
|
+
}>;
|
|
2653
|
+
update: (data: Partial<ModelWithoutRelations<T>>, options?: UpdateOptions, returnType?: "millis" | "seconds") => Promise<{
|
|
2654
|
+
data: number;
|
|
2655
|
+
time: number;
|
|
2656
|
+
}>;
|
|
2657
|
+
softDelete: (options?: Omit<SoftDeleteOptions<T>, "ignoreBeforeDeleteHook">, returnType?: "millis" | "seconds") => Promise<{
|
|
2658
|
+
data: number;
|
|
2659
|
+
time: number;
|
|
2660
|
+
}>;
|
|
2609
2661
|
};
|
|
2610
2662
|
constructor(model: typeof Model, sqlDataSource: SqlDataSource);
|
|
2611
2663
|
/**
|
|
@@ -2633,13 +2685,6 @@ declare class ModelQueryBuilder<T extends Model, A extends Record<string, any> =
|
|
|
2633
2685
|
chunk(chunkSize: number, options?: ManyOptions): AsyncGenerator<AnnotatedModel<T, A, R>[]>;
|
|
2634
2686
|
stream(options?: ManyOptions & StreamOptions, cb?: (stream: PassThrough & AsyncGenerator<AnnotatedModel<T, A, R>>) => void | Promise<void>): Promise<PassThrough & AsyncGenerator<AnnotatedModel<T, A, R>>>;
|
|
2635
2687
|
paginateWithCursor<K extends ModelKey<T>>(page: number, options?: PaginateWithCursorOptions<T, K>, cursor?: Cursor<T, K>): Promise<[CursorPaginatedData<T, A, R>, Cursor<T, K>]>;
|
|
2636
|
-
private manyWithPerformance;
|
|
2637
|
-
private oneWithPerformance;
|
|
2638
|
-
private oneOrFailWithPerformance;
|
|
2639
|
-
private firstOrFailWithPerformance;
|
|
2640
|
-
private firstWithPerformance;
|
|
2641
|
-
private paginateWithPerformance;
|
|
2642
|
-
private paginateWithCursorWithPerformance;
|
|
2643
2688
|
update(data: Partial<ModelWithoutRelations<T>>, options?: UpdateOptions): Promise<number>;
|
|
2644
2689
|
softDelete(options?: SoftDeleteOptions<T>): Promise<number>;
|
|
2645
2690
|
delete(options?: DeleteOptions): Promise<number>;
|
|
@@ -2754,6 +2799,21 @@ declare class ModelQueryBuilder<T extends Model, A extends Record<string, any> =
|
|
|
2754
2799
|
protected getFilterValuesFromModelsForRelation(relation: Relation, models: T[]): any[];
|
|
2755
2800
|
protected applyHavingRelatedFilter(relationQueryBuilder: ModelQueryBuilder<any>, relation: Relation, operator?: BinaryOperatorType$1, value?: BaseValues$1): void;
|
|
2756
2801
|
protected addAdditionalColumnsToModel(row: any, typeofModel: typeof Model): Record<string, any>;
|
|
2802
|
+
private manyWithPerformance;
|
|
2803
|
+
private oneWithPerformance;
|
|
2804
|
+
private oneOrFailWithPerformance;
|
|
2805
|
+
private firstOrFailWithPerformance;
|
|
2806
|
+
private firstWithPerformance;
|
|
2807
|
+
private paginateWithPerformance;
|
|
2808
|
+
private paginateWithCursorWithPerformance;
|
|
2809
|
+
private existsWithPerformance;
|
|
2810
|
+
private pluckWithPerformance;
|
|
2811
|
+
private softDeleteWithPerformance;
|
|
2812
|
+
private updateWithPerformance;
|
|
2813
|
+
private insertWithPerformance;
|
|
2814
|
+
private insertManyWithPerformance;
|
|
2815
|
+
private deleteWithPerformance;
|
|
2816
|
+
private truncateWithPerformance;
|
|
2757
2817
|
}
|
|
2758
2818
|
|
|
2759
2819
|
declare class ModelManager<T extends Model> {
|
|
@@ -2935,7 +2995,7 @@ declare class SqlDataSource extends DataSource {
|
|
|
2935
2995
|
* @description Optimal for performance-critical operations
|
|
2936
2996
|
* @description Use Models to have type safety and serialization
|
|
2937
2997
|
*/
|
|
2938
|
-
static query(table: string): QueryBuilder;
|
|
2998
|
+
static query(table: string, options?: RawModelOptions): QueryBuilder;
|
|
2939
2999
|
/**
|
|
2940
3000
|
* @description Creates a table on the database, return the query to be executed to create the table
|
|
2941
3001
|
*/
|
|
@@ -3026,8 +3086,9 @@ declare class SqlDataSource extends DataSource {
|
|
|
3026
3086
|
* @description Query builder from the SqlDataSource instance uses raw data from the database so the data is not parsed or serialized in any way
|
|
3027
3087
|
* @description Optimal for performance-critical operations
|
|
3028
3088
|
* @description Use Models to have type safety and serialization
|
|
3089
|
+
* @description Default soft delete column is "deleted_at" with stringed date value
|
|
3029
3090
|
*/
|
|
3030
|
-
query(table: string): QueryBuilder;
|
|
3091
|
+
query(table: string, options?: RawModelOptions): QueryBuilder;
|
|
3031
3092
|
/**
|
|
3032
3093
|
* @description Return the query to alter the given table schema
|
|
3033
3094
|
*/
|
|
@@ -3173,6 +3234,9 @@ type SqlPoolType = MysqlConnectionInstance | PgPoolClientInstance | SqliteConnec
|
|
|
3173
3234
|
* @default By default, the connection policies are not set, so no query will be retried
|
|
3174
3235
|
*/
|
|
3175
3236
|
type ConnectionPolicies = {
|
|
3237
|
+
/**
|
|
3238
|
+
* @description The retry policy for the sql data source, it allows to retry a query if it fails
|
|
3239
|
+
*/
|
|
3176
3240
|
retry?: {
|
|
3177
3241
|
maxRetries?: number;
|
|
3178
3242
|
delay?: number;
|
|
@@ -3293,21 +3357,36 @@ declare class QueryBuilder<T extends Model = any> extends JsonQueryBuilder<T> {
|
|
|
3293
3357
|
data: boolean;
|
|
3294
3358
|
time: number;
|
|
3295
3359
|
}>;
|
|
3360
|
+
truncate: (returnType?: "millis" | "seconds") => Promise<{
|
|
3361
|
+
data: void;
|
|
3362
|
+
time: number;
|
|
3363
|
+
}>;
|
|
3364
|
+
delete: (returnType?: "millis" | "seconds") => Promise<{
|
|
3365
|
+
data: number;
|
|
3366
|
+
time: number;
|
|
3367
|
+
}>;
|
|
3368
|
+
insert: (data: Record<string, any>, returnType?: "millis" | "seconds") => Promise<{
|
|
3369
|
+
data: T;
|
|
3370
|
+
time: number;
|
|
3371
|
+
}>;
|
|
3372
|
+
insertMany: (data: Record<string, any>[], returnType?: "millis" | "seconds") => Promise<{
|
|
3373
|
+
data: T[];
|
|
3374
|
+
time: number;
|
|
3375
|
+
}>;
|
|
3376
|
+
update: (data: Record<string, any>, returnType?: "millis" | "seconds") => Promise<{
|
|
3377
|
+
data: number;
|
|
3378
|
+
time: number;
|
|
3379
|
+
}>;
|
|
3380
|
+
softDelete: (options?: Omit<SoftDeleteOptions<T>, "ignoreBeforeDeleteHook">, returnType?: "millis" | "seconds") => Promise<{
|
|
3381
|
+
data: number;
|
|
3382
|
+
time: number;
|
|
3383
|
+
}>;
|
|
3296
3384
|
};
|
|
3297
3385
|
constructor(model: typeof Model, sqlDataSource?: SqlDataSource);
|
|
3298
|
-
protected get fromTable(): string;
|
|
3299
3386
|
/**
|
|
3300
3387
|
* @description Executes the query and returns true if the query returns at least one result, false otherwise.
|
|
3301
3388
|
*/
|
|
3302
3389
|
exists(): Promise<boolean>;
|
|
3303
|
-
/**
|
|
3304
|
-
* @description Executes the query and returns true if the query returns at least one result, false otherwise.
|
|
3305
|
-
* @description Returns the time that took to execute the query
|
|
3306
|
-
*/
|
|
3307
|
-
existsWithPerformance(returnType?: "millis" | "seconds"): Promise<{
|
|
3308
|
-
data: boolean;
|
|
3309
|
-
time: number;
|
|
3310
|
-
}>;
|
|
3311
3390
|
/**
|
|
3312
3391
|
* @description Executes the query and retrieves multiple results.
|
|
3313
3392
|
*/
|
|
@@ -3418,19 +3497,21 @@ declare class QueryBuilder<T extends Model = any> extends JsonQueryBuilder<T> {
|
|
|
3418
3497
|
unionAll(cb: UnionCallBack<T>): this;
|
|
3419
3498
|
unionAll(queryBuilder: QueryBuilder<any>): this;
|
|
3420
3499
|
/**
|
|
3421
|
-
* @description Increments the value of a column by a given amount
|
|
3500
|
+
* @description Increments the value of a column by a given amount
|
|
3422
3501
|
* @typeSafe - In typescript, only numeric columns of the model will be accepted if using a Model
|
|
3423
3502
|
* @default value + 1
|
|
3424
3503
|
* @returns the number of affected rows
|
|
3425
3504
|
*/
|
|
3426
|
-
increment(column:
|
|
3505
|
+
increment(column: string, value: number): Promise<number>;
|
|
3506
|
+
increment(column: NumberModelKey<T>, value: number): Promise<number>;
|
|
3427
3507
|
/**
|
|
3428
|
-
* @description Decrements the value of a column by a given amount
|
|
3508
|
+
* @description Decrements the value of a column by a given amount
|
|
3429
3509
|
* @typeSafe - In typescript, only numeric columns of the model will be accepted if using a Model
|
|
3430
3510
|
* @default value - 1
|
|
3431
3511
|
* @returns the number of affected rows
|
|
3432
3512
|
*/
|
|
3433
|
-
decrement(column:
|
|
3513
|
+
decrement(column: string, value: number): Promise<number>;
|
|
3514
|
+
decrement(column: NumberModelKey<T>, value: number): Promise<number>;
|
|
3434
3515
|
/**
|
|
3435
3516
|
* @description Executes the query and retrieves the count of results, it ignores all select, group by, order by, limit and offset clauses if they are present.
|
|
3436
3517
|
*/
|
|
@@ -3507,7 +3588,7 @@ declare class QueryBuilder<T extends Model = any> extends JsonQueryBuilder<T> {
|
|
|
3507
3588
|
* @default value - The current date and time in UTC timezone in the format "YYYY-MM-DD HH:mm:ss"
|
|
3508
3589
|
* @returns the number of affected rows
|
|
3509
3590
|
*/
|
|
3510
|
-
softDelete(options?: SoftDeleteOptions<T>): Promise<number>;
|
|
3591
|
+
softDelete(options?: Omit<SoftDeleteOptions<T>, "ignoreBeforeDeleteHook">): Promise<number>;
|
|
3511
3592
|
/**
|
|
3512
3593
|
* @description Returns the query with the parameters bound to the query
|
|
3513
3594
|
*/
|
|
@@ -3520,9 +3601,22 @@ declare class QueryBuilder<T extends Model = any> extends JsonQueryBuilder<T> {
|
|
|
3520
3601
|
* @description Returns a deep clone of the query builder instance.
|
|
3521
3602
|
*/
|
|
3522
3603
|
clone(): this;
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3604
|
+
/**
|
|
3605
|
+
* @description Gives a fresh instance of the query builder
|
|
3606
|
+
*/
|
|
3607
|
+
clear(): QueryBuilder<any>;
|
|
3608
|
+
/**
|
|
3609
|
+
* @description Removes the lock query
|
|
3610
|
+
*/
|
|
3611
|
+
clearLockQuery(): this;
|
|
3612
|
+
/**
|
|
3613
|
+
* @description Removes any union query
|
|
3614
|
+
*/
|
|
3615
|
+
clearUnionQuery(): this;
|
|
3616
|
+
/**
|
|
3617
|
+
* @description Removes any with query
|
|
3618
|
+
*/
|
|
3619
|
+
clearWithQuery(): this;
|
|
3526
3620
|
extractQueryNodes(): QueryNode[];
|
|
3527
3621
|
protected clearForFunctions(): this;
|
|
3528
3622
|
/**
|
|
@@ -3547,18 +3641,30 @@ declare class QueryBuilder<T extends Model = any> extends JsonQueryBuilder<T> {
|
|
|
3547
3641
|
* @description Makes a one or fail query and returns the time that took to execute that query
|
|
3548
3642
|
*/
|
|
3549
3643
|
private oneOrFailWithPerformance;
|
|
3644
|
+
/**
|
|
3645
|
+
* @description Executes the query and returns true if the query returns at least one result, false otherwise.
|
|
3646
|
+
* @description Returns the time that took to execute the query
|
|
3647
|
+
*/
|
|
3648
|
+
private existsWithPerformance;
|
|
3649
|
+
private pluckWithPerformance;
|
|
3650
|
+
private updateWithPerformance;
|
|
3651
|
+
private insertWithPerformance;
|
|
3652
|
+
private insertManyWithPerformance;
|
|
3653
|
+
private softDeleteWithPerformance;
|
|
3654
|
+
private deleteWithPerformance;
|
|
3655
|
+
private truncateWithPerformance;
|
|
3550
3656
|
}
|
|
3551
3657
|
|
|
3552
3658
|
type UnionCallBack<T extends Model> = (queryBuilder: QueryBuilder<T>) => QueryBuilder<T>;
|
|
3553
3659
|
type SqlMethod = "sum" | "avg" | "max" | "min" | "count" | "upper" | "lower" | "trim" | "length" | "cast" | "convert" | "abs" | "round" | "floor" | "ceil";
|
|
3554
3660
|
|
|
3555
3661
|
type ModelInstanceType<O> = O extends typeof Model ? InstanceType<O> : never;
|
|
3556
|
-
type FetchHooks = "beforeFetch" | "afterFetch";
|
|
3662
|
+
type FetchHooks = ["afterFetch"] | ["beforeFetch"] | ["afterFetch", "beforeFetch"] | ["beforeFetch", "afterFetch"] | [];
|
|
3557
3663
|
type OneOptions = {
|
|
3558
|
-
ignoreHooks?: FetchHooks
|
|
3664
|
+
ignoreHooks?: FetchHooks;
|
|
3559
3665
|
};
|
|
3560
3666
|
type ManyOptions = {
|
|
3561
|
-
ignoreHooks?: FetchHooks
|
|
3667
|
+
ignoreHooks?: FetchHooks;
|
|
3562
3668
|
};
|
|
3563
3669
|
type AnnotatedModel<T extends Model, A extends object = {}, R extends object = {}> = [keyof A] extends [never] ? ModelWithoutRelations<T> & R : ModelWithoutRelations<T> & {
|
|
3564
3670
|
$annotations: A;
|
|
@@ -3648,7 +3754,7 @@ type OrderByType<T extends Model> = {
|
|
|
3648
3754
|
type UnrestrictedFindOneType<T extends Model, S extends ModelKey<T>[] = any[], R extends ModelRelation<T>[] = never[]> = {
|
|
3649
3755
|
select?: S;
|
|
3650
3756
|
relations?: R;
|
|
3651
|
-
ignoreHooks?: FetchHooks
|
|
3757
|
+
ignoreHooks?: FetchHooks;
|
|
3652
3758
|
where?: Record<string, any>;
|
|
3653
3759
|
orderBy?: OrderByType<T>;
|
|
3654
3760
|
groupBy?: string[];
|
|
@@ -3664,7 +3770,7 @@ type FindOneType<T extends Model, S extends ModelKey<T>[] = any[], R extends Mod
|
|
|
3664
3770
|
orderBy?: OrderByType<T>;
|
|
3665
3771
|
groupBy?: ModelKey<T>[];
|
|
3666
3772
|
where?: WhereType<T>;
|
|
3667
|
-
ignoreHooks?: FetchHooks
|
|
3773
|
+
ignoreHooks?: FetchHooks;
|
|
3668
3774
|
};
|
|
3669
3775
|
type FindType<T extends Model, S extends ModelKey<T>[] = any[], R extends ModelRelation<T>[] = never[]> = Omit<FindOneType<T, S, R>, "throwErrorOnNull"> & {
|
|
3670
3776
|
limit?: number;
|
|
@@ -3692,7 +3798,7 @@ declare abstract class Model extends Entity {
|
|
|
3692
3798
|
* @description The value used to soft delete a record, default is the current date and time
|
|
3693
3799
|
* @default format: "YYYY-MM-DD HH:mm:ss" in UTC timezone
|
|
3694
3800
|
*/
|
|
3695
|
-
static softDeleteValue: string;
|
|
3801
|
+
static softDeleteValue: boolean | string;
|
|
3696
3802
|
/**
|
|
3697
3803
|
* @description The sql sqlInstance generated by SqlDataSource.connect
|
|
3698
3804
|
*/
|
|
@@ -3853,7 +3959,7 @@ declare abstract class Model extends Entity {
|
|
|
3853
3959
|
/**
|
|
3854
3960
|
* @description Adds a beforeFetch clause to the model, adding the ability to modify the query before fetching the data
|
|
3855
3961
|
*/
|
|
3856
|
-
static beforeFetch?(queryBuilder: ModelQueryBuilder<any>): void;
|
|
3962
|
+
static beforeFetch?(queryBuilder: ModelQueryBuilder<any>): Promise<void> | void;
|
|
3857
3963
|
/**
|
|
3858
3964
|
* @description Adds a beforeInsert clause to the model, adding the ability to modify the data before inserting the data
|
|
3859
3965
|
* @param {Model} data The single model to be inserted, in insertMany the hook will be called for each model
|
|
@@ -3868,11 +3974,11 @@ declare abstract class Model extends Entity {
|
|
|
3868
3974
|
/**
|
|
3869
3975
|
* @description Adds a beforeUpdate clause to the model, adding the ability to modify the query before updating the data
|
|
3870
3976
|
*/
|
|
3871
|
-
static beforeUpdate?(queryBuilder: ModelQueryBuilder<any>): void;
|
|
3977
|
+
static beforeUpdate?(queryBuilder: ModelQueryBuilder<any>): Promise<void> | void;
|
|
3872
3978
|
/**
|
|
3873
3979
|
* @description Adds a beforeDelete clause to the model, adding the ability to modify the query before deleting the data
|
|
3874
3980
|
*/
|
|
3875
|
-
static beforeDelete?(queryBuilder: ModelQueryBuilder<any>): void;
|
|
3981
|
+
static beforeDelete?(queryBuilder: ModelQueryBuilder<any>): Promise<void> | void;
|
|
3876
3982
|
/**
|
|
3877
3983
|
* @description Adds a afterFetch clause to the model, adding the ability to modify the data after fetching the data
|
|
3878
3984
|
* @param {Model} data The single model to be fetched, in queries that return multiple models the hook will be called for each model
|
|
@@ -4346,7 +4452,7 @@ type WithPerformanceResult<R = any> = [string, R];
|
|
|
4346
4452
|
* @param `fix` Number of digits in the decimal part of the performance result
|
|
4347
4453
|
* @returns An array with the millis or seconds that the function took as first element, and the result of the async function as second element
|
|
4348
4454
|
*/
|
|
4349
|
-
declare const withPerformance: <
|
|
4455
|
+
declare const withPerformance: <A extends any[], R>(fn: (...args: A) => Promise<R>, returnType?: "millis" | "seconds", fix?: number) => (...args: A) => Promise<WithPerformanceResult<R>>;
|
|
4350
4456
|
|
|
4351
4457
|
type HysteriaErrorCode = "ROW_NOT_FOUND" | `UNSUPPORTED_DATABASE_TYPE_${string}` | `RELATION_TYPE_NOT_SUPPORTED_${string}` | `NOT_SUPPORTED_IN_${string}` | `RELATION_NOT_FOUND_IN_MODEL_${string}` | `UNKNOWN_RELATION_TYPE_${string}` | `DISTINCT_ON_NOT_SUPPORTED_IN_${string}` | `CONFLICT_COLUMNS_NOT_PRESENT_IN_DATA` | `CONFLICT_COLUMNS_NOT_PRESENT_IN_DATA_${string}` | `FOREIGN_KEY_VALUES_MISSING_FOR_HAS_ONE_RELATION_${string}` | `FOREIGN_KEY_VALUES_MISSING_FOR_BELONGS_TO_RELATION_${string}` | `PRIMARY_KEY_VALUES_MISSING_FOR_HAS_MANY_RELATION_${string}` | `MANY_TO_MANY_RELATION_NOT_FOUND_FOR_RELATED_MODEL_${string}` | `PRIMARY_KEY_VALUES_MISSING_FOR_MANY_TO_MANY_RELATION_${string}` | `RELATED_MODEL_DOES_NOT_HAVE_A_PRIMARY_KEY_${string}` | `FOR_SHARE_NOT_SUPPORTED_IN_${string}` | `SKIP_LOCKED_NOT_SUPPORTED_IN_${string}` | `LOCK_FOR_UPDATE_NOT_SUPPORTED_${string}` | `SQLITE_NOT_SUPPORTED` | `COCKROACHDB_NOT_SUPPORTED` | `RELATION_NOT_FOUND` | `POSTGRES_TABLE_REQUIRED` | `RELATION_NOT_MANY_TO_MANY` | "MATERIALIZED_CTE_NOT_SUPPORTED" | "DUPLICATE_MODEL_KEYS_WHILE_INSTANTIATING_MODELS" | "INVALID_ONE_PARAMETER_WHERE_CONDITION" | "INVALID_PAGINATION_PARAMETERS" | "MISSING_ALIAS_FOR_SUBQUERY" | "MODEL_HAS_NO_PRIMARY_KEY" | "PRIMARY_KEY_NOT_FOUND" | "SQLITE_ONLY_SUPPORTS_SERIALIZABLE_ISOLATION_LEVEL" | "MUST_CALL_BUILD_CTE_AT_LEAST_ONCE" | "REGEXP_NOT_SUPPORTED_IN_SQLITE" | "MANY_TO_MANY_RELATION_MUST_HAVE_A_THROUGH_MODEL" | "INSERT_FAILED" | "MULTIPLE_PRIMARY_KEYS_NOT_ALLOWED" | "FILE_NOT_A_SQL_OR_TXT_FILE" | "CONNECTION_NOT_ESTABLISHED" | "TRANSACTION_NOT_ACTIVE" | "DEVELOPMENT_ERROR" | "MIGRATION_MODULE_NOT_FOUND" | "DRIVER_NOT_FOUND" | "FILE_NOT_FOUND_OR_NOT_ACCESSIBLE" | "ENV_NOT_SET" | "REQUIRED_VALUE_NOT_SET" | "SET_FAILED" | "GET_FAILED" | "REFERENCES_OPTION_REQUIRED" | "DELETE_FAILED" | "INVALID_DEFAULT_VALUE" | "DISCONNECT_FAILED" | "FLUSH_FAILED" | "LEFT_COLUMN_NOT_PROVIDED_FOR_JOIN" | "RIGHT_COLUMN_NOT_PROVIDED_FOR_JOIN" | "MODEL_HAS_NO_PRIMARY_KEY" | "GLOBAL_TRANSACTION_ALREADY_STARTED" | "GLOBAL_TRANSACTION_NOT_STARTED" | "MYSQL_REQUIRES_TABLE_NAME_FOR_INDEX_DROP" | "INVALID_DATE_OBJECT" | "INVALID_DATE_STRING" | "FAILED_TO_PARSE_DATE" | "MIGRATION_MODULE_REQUIRES_TS_NODE" | "FAILED_TO_ENCRYPT_SYMMETRICALLY" | "FAILED_TO_DECRYPT_SYMMETRICALLY" | "FAILED_TO_ENCRYPT_ASYMMETRICALLY" | "FAILED_TO_DECRYPT_ASYMMETRICALLY" | "UNSUPPORTED_RELATION_TYPE";
|
|
4352
4458
|
|
|
@@ -4372,4 +4478,4 @@ declare const generateOpenApiModelWithMetadata: <T extends new () => Model>(mode
|
|
|
4372
4478
|
modelName: string;
|
|
4373
4479
|
}>;
|
|
4374
4480
|
|
|
4375
|
-
export { type AnnotatedModel, type AsymmetricEncryptionOptions, type AugmentedSqlDataSource, AutogeneratedModel, type BaseModelMethodOptions, type BaseModelRelationType, ClientMigrator, Collection, type ColumnDataTypeOption, type ColumnDataTypeOptionSimple, type ColumnDataTypeOptionWithBinary, type ColumnDataTypeOptionWithDatePrecision, type ColumnDataTypeOptionWithEnum, type ColumnDataTypeOptionWithLength, type ColumnDataTypeOptionWithPrecision, type ColumnDataTypeOptionWithScaleAndPrecision, type ColumnDataTypeOptionWithText, type ColumnOptions, type ColumnType, type CommonDataSourceInput, type CommonSqlMethodReturnType, type ConnectionPolicies, type DataSourceInput, type DataSourceType, type DateColumnOptions, type FetchHooks, type GetConnectionReturnType, HysteriaError, type IndexType, type LazyRelationType, type ManyOptions, type ManyToManyOptions, Migration, Model, type ModelInstanceType, ModelQueryBuilder, type ModelWithoutRelations, MongoDataSource, type MongoDataSourceInput, type MysqlConnectionInstance, type MysqlSqlDataSourceInput, type NotNullableMysqlSqlDataSourceInput, type NotNullablePostgresSqlDataSourceInput, type NotNullableSqliteDataSourceInput, type NumberModelKey, type OneOptions, type PgPoolClientInstance, type PostgresSqlDataSourceInput, QueryBuilder, type RedisFetchable, type RedisStorable, type RelatedInstance, type RelationQueryBuilderType, type SqlCloneOptions, type SqlDataSourceInput, type SqlDataSourceModel, type SqlDataSourceType, type SqlDataSourceWithoutTransaction, type SqlDriverSpecificOptions, type SqlPoolType, type SqliteConnectionInstance, type SqliteDataSourceInput, type StartTransactionOptions, type SymmetricEncryptionOptions, type ThroughModel, TimestampedModel, Transaction, type TransactionExecutionOptions, type UniqueType, type UseConnectionInput, User, UuidModel, belongsTo, column, createModelFactory, defineMigrator, generateOpenApiModel, generateOpenApiModelSchema, generateOpenApiModelWithMetadata, getCollectionProperties, getIndexes, getModelColumns, type getPoolReturnType, getPrimaryKey, getRelations, getRelationsMetadata, getUniques, hasMany, hasOne, index, HysteriaLogger as logger, manyToMany, MongoDataSource as mongo, property, RedisDataSource as redis, SqlDataSource as sql, unique, view, withPerformance };
|
|
4481
|
+
export { type AnnotatedModel, type AsymmetricEncryptionOptions, type AugmentedSqlDataSource, AutogeneratedModel, type BaseModelMethodOptions, type BaseModelRelationType, ClientMigrator, Collection, type ColumnDataTypeOption, type ColumnDataTypeOptionSimple, type ColumnDataTypeOptionWithBinary, type ColumnDataTypeOptionWithDatePrecision, type ColumnDataTypeOptionWithEnum, type ColumnDataTypeOptionWithLength, type ColumnDataTypeOptionWithPrecision, type ColumnDataTypeOptionWithScaleAndPrecision, type ColumnDataTypeOptionWithText, type ColumnOptions, type ColumnType, type CommonDataSourceInput, type CommonSqlMethodReturnType, type ConnectionPolicies, type DataSourceInput, type DataSourceType, type DateColumnOptions, type FetchHooks, type GetConnectionReturnType, HysteriaError, type IndexType, type LazyRelationType, type ManyOptions, type ManyToManyOptions, Migration, Model, type ModelInstanceType, ModelQueryBuilder, type ModelWithoutRelations, MongoDataSource, type MongoDataSourceInput, type MysqlConnectionInstance, type MysqlSqlDataSourceInput, type NotNullableMysqlSqlDataSourceInput, type NotNullablePostgresSqlDataSourceInput, type NotNullableSqliteDataSourceInput, type NumberModelKey, type OneOptions, type PgPoolClientInstance, type PostgresSqlDataSourceInput, QueryBuilder, type RawModelOptions, type RedisFetchable, type RedisStorable, type RelatedInstance, type RelationQueryBuilderType, type SqlCloneOptions, type SqlDataSourceInput, type SqlDataSourceModel, type SqlDataSourceType, type SqlDataSourceWithoutTransaction, type SqlDriverSpecificOptions, type SqlPoolType, type SqliteConnectionInstance, type SqliteDataSourceInput, type StartTransactionOptions, type SymmetricEncryptionOptions, type ThroughModel, TimestampedModel, Transaction, type TransactionExecutionOptions, type UniqueType, type UseConnectionInput, User, UuidModel, belongsTo, column, createModelFactory, defineMigrator, generateOpenApiModel, generateOpenApiModelSchema, generateOpenApiModelWithMetadata, getCollectionProperties, getIndexes, getModelColumns, type getPoolReturnType, getPrimaryKey, getRelations, getRelationsMetadata, getUniques, hasMany, hasOne, index, HysteriaLogger as logger, manyToMany, MongoDataSource as mongo, property, RedisDataSource as redis, SqlDataSource as sql, unique, view, withPerformance };
|