hysteria-orm 10.0.3 → 10.0.5
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 +14 -14
- package/lib/cli.cjs.map +1 -1
- package/lib/cli.js +14 -14
- package/lib/cli.js.map +1 -1
- package/lib/index.cjs +17 -17
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +1041 -293
- package/lib/index.d.ts +1041 -293
- package/lib/index.js +17 -17
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import * as mongodb from 'mongodb';
|
|
2
|
+
import { Collection as Collection$1 } from 'mongodb';
|
|
2
3
|
import * as sqlite3 from 'sqlite3';
|
|
3
4
|
import * as pg from 'pg';
|
|
4
5
|
import { PoolClient } from 'pg';
|
|
5
6
|
import * as mysql2_promise from 'mysql2/promise';
|
|
6
7
|
import { PoolConnection } from 'mysql2/promise';
|
|
8
|
+
import { RedisOptions, Redis } from 'ioredis';
|
|
7
9
|
import { PassThrough } from 'node:stream';
|
|
8
10
|
import { FormatOptionsWithLanguage } from 'sql-formatter';
|
|
9
|
-
import { Redis, RedisOptions } from 'ioredis';
|
|
10
11
|
|
|
11
12
|
type CaseConvention = "camel" | "snake" | "preserve" | RegExp | ((column: string) => string);
|
|
12
13
|
|
|
@@ -28,6 +29,68 @@ declare abstract class Entity {
|
|
|
28
29
|
static databaseCaseConvention: CaseConvention;
|
|
29
30
|
}
|
|
30
31
|
|
|
32
|
+
/**
|
|
33
|
+
* @description Creates a datasource for the selected database type with the provided credentials
|
|
34
|
+
*/
|
|
35
|
+
type DataSourceType = "cockroachdb" | "mysql" | "postgres" | "mariadb" | "sqlite" | "mongo";
|
|
36
|
+
interface CommonDataSourceInput {
|
|
37
|
+
readonly type?: DataSourceType;
|
|
38
|
+
readonly logs?: boolean;
|
|
39
|
+
}
|
|
40
|
+
interface MongoDataSourceInput extends CommonDataSourceInput {
|
|
41
|
+
readonly type: "mongo";
|
|
42
|
+
readonly mongoOptions?: MongoConnectionOptions;
|
|
43
|
+
readonly url?: string;
|
|
44
|
+
}
|
|
45
|
+
interface PostgresSqlDataSourceInput extends CommonDataSourceInput {
|
|
46
|
+
readonly type?: "postgres" | "cockroachdb";
|
|
47
|
+
readonly host?: string;
|
|
48
|
+
readonly port?: number;
|
|
49
|
+
readonly username?: string;
|
|
50
|
+
readonly password?: string;
|
|
51
|
+
readonly database?: string;
|
|
52
|
+
readonly driverOptions?: PgClientOptions;
|
|
53
|
+
}
|
|
54
|
+
interface NotNullablePostgresSqlDataSourceInput extends PostgresSqlDataSourceInput {
|
|
55
|
+
readonly type?: "postgres" | "cockroachdb";
|
|
56
|
+
readonly host: string;
|
|
57
|
+
readonly username: string;
|
|
58
|
+
readonly password: string;
|
|
59
|
+
readonly database: string;
|
|
60
|
+
readonly port?: number;
|
|
61
|
+
readonly driverOptions?: PgClientOptions;
|
|
62
|
+
}
|
|
63
|
+
interface MysqlSqlDataSourceInput extends CommonDataSourceInput {
|
|
64
|
+
readonly type?: "mysql" | "mariadb";
|
|
65
|
+
readonly host?: string;
|
|
66
|
+
readonly port?: number;
|
|
67
|
+
readonly username?: string;
|
|
68
|
+
readonly password?: string;
|
|
69
|
+
readonly database?: string;
|
|
70
|
+
readonly driverOptions?: MysqlCreateConnectionOptions;
|
|
71
|
+
}
|
|
72
|
+
interface NotNullableMysqlSqlDataSourceInput extends MysqlSqlDataSourceInput {
|
|
73
|
+
readonly type?: "mysql" | "mariadb";
|
|
74
|
+
readonly host: string;
|
|
75
|
+
readonly username: string;
|
|
76
|
+
readonly password: string;
|
|
77
|
+
readonly database: string;
|
|
78
|
+
readonly port?: number;
|
|
79
|
+
readonly driverOptions?: MysqlCreateConnectionOptions;
|
|
80
|
+
}
|
|
81
|
+
interface SqliteDataSourceInput extends CommonDataSourceInput {
|
|
82
|
+
readonly type?: "sqlite";
|
|
83
|
+
readonly database?: string;
|
|
84
|
+
}
|
|
85
|
+
interface NotNullableSqliteDataSourceInput extends SqliteDataSourceInput {
|
|
86
|
+
readonly type?: "sqlite";
|
|
87
|
+
readonly database: string;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* @description By default the connection details can be provided in the .env file, you can still override each prop with your actual connection details in the input
|
|
91
|
+
*/
|
|
92
|
+
type DataSourceInput = MysqlSqlDataSourceInput | SqliteDataSourceInput | PostgresSqlDataSourceInput | MongoDataSourceInput;
|
|
93
|
+
|
|
31
94
|
type Mysql2Import = typeof mysql2_promise;
|
|
32
95
|
type PgImport = typeof pg;
|
|
33
96
|
type Sqlite3Import = typeof sqlite3;
|
|
@@ -36,11 +99,7 @@ type ExcludeStringFromOptions<T> = T extends string ? never : T;
|
|
|
36
99
|
type MysqlCreateConnectionOptions = Parameters<Mysql2Import["createPool"]>[0];
|
|
37
100
|
type PgClientOptions = ExcludeStringFromOptions<ConstructorParameters<PgImport["Pool"]>[0]>;
|
|
38
101
|
type MongoConnectionOptions = NonNullable<ConstructorParameters<MongoClientImport["MongoClient"]>[1]>;
|
|
39
|
-
type DriverSpecificOptions =
|
|
40
|
-
mysqlOptions?: MysqlCreateConnectionOptions;
|
|
41
|
-
pgOptions?: PgClientOptions;
|
|
42
|
-
mongoOptions?: MongoConnectionOptions;
|
|
43
|
-
};
|
|
102
|
+
type DriverSpecificOptions<T extends DataSourceType> = T extends "mongo" ? MongoConnectionOptions : T extends "cockroachdb" ? PgClientOptions : T extends "redis" ? RedisOptions : T extends "postgres" ? PgClientOptions : T extends "mongo" ? MongoConnectionOptions : T extends "mariadb" ? MysqlCreateConnectionOptions : T extends "mysql" ? MysqlCreateConnectionOptions : never;
|
|
44
103
|
|
|
45
104
|
type MongoCollectionKey<T> = T extends Collection ? T : never;
|
|
46
105
|
type BaseModelMethodOptions$1 = {
|
|
@@ -65,7 +124,7 @@ type ModelKeyOrAnySort<T> = {
|
|
|
65
124
|
};
|
|
66
125
|
|
|
67
126
|
type FetchHooks$1 = "beforeFetch" | "afterFetch";
|
|
68
|
-
type BinaryOperatorType$2 = "$eq" | "$ne" | "$gt" | "$gte" | "$lt" | "$lte";
|
|
127
|
+
type BinaryOperatorType$2 = "$eq" | "$ne" | "$gt" | "$gte" | "$lt" | "$lte" | "$in" | "$nin";
|
|
69
128
|
type BaseValues$2 = string | number | boolean | Date | Array<string | number | boolean | Date>;
|
|
70
129
|
type OneOptions$1 = {
|
|
71
130
|
throwErrorOnNull?: boolean;
|
|
@@ -83,7 +142,7 @@ declare class MongoQueryBuilder<T extends Collection> {
|
|
|
83
142
|
protected limitNumber?: number;
|
|
84
143
|
protected offsetNumber?: number;
|
|
85
144
|
protected mongoDataSource: MongoDataSource;
|
|
86
|
-
protected collection:
|
|
145
|
+
protected collection: Collection$1<T>;
|
|
87
146
|
protected model: typeof Collection;
|
|
88
147
|
protected logs: boolean;
|
|
89
148
|
protected session?: ReturnType<MongoDataSource["startSession"]>;
|
|
@@ -367,68 +426,6 @@ declare class MongoQueryBuilder<T extends Collection> {
|
|
|
367
426
|
offset(offset: number): this;
|
|
368
427
|
}
|
|
369
428
|
|
|
370
|
-
/**
|
|
371
|
-
* @description Creates a datasource for the selected database type with the provided credentials
|
|
372
|
-
*/
|
|
373
|
-
type DataSourceType = "cockroachdb" | "mysql" | "postgres" | "mariadb" | "sqlite" | "mongo";
|
|
374
|
-
interface CommonDataSourceInput {
|
|
375
|
-
readonly type?: DataSourceType;
|
|
376
|
-
readonly logs?: boolean;
|
|
377
|
-
}
|
|
378
|
-
interface MongoDataSourceInput extends CommonDataSourceInput {
|
|
379
|
-
readonly type: "mongo";
|
|
380
|
-
readonly mongoOptions?: MongoConnectionOptions;
|
|
381
|
-
readonly url?: string;
|
|
382
|
-
}
|
|
383
|
-
interface PostgresSqlDataSourceInput extends CommonDataSourceInput {
|
|
384
|
-
readonly type?: "postgres" | "cockroachdb";
|
|
385
|
-
readonly host?: string;
|
|
386
|
-
readonly port?: number;
|
|
387
|
-
readonly username?: string;
|
|
388
|
-
readonly password?: string;
|
|
389
|
-
readonly database?: string;
|
|
390
|
-
readonly driverOptions?: PgClientOptions;
|
|
391
|
-
}
|
|
392
|
-
interface NotNullablePostgresSqlDataSourceInput extends PostgresSqlDataSourceInput {
|
|
393
|
-
readonly type?: "postgres" | "cockroachdb";
|
|
394
|
-
readonly host: string;
|
|
395
|
-
readonly username: string;
|
|
396
|
-
readonly password: string;
|
|
397
|
-
readonly database: string;
|
|
398
|
-
readonly port?: number;
|
|
399
|
-
readonly driverOptions?: PgClientOptions;
|
|
400
|
-
}
|
|
401
|
-
interface MysqlSqlDataSourceInput extends CommonDataSourceInput {
|
|
402
|
-
readonly type?: "mysql" | "mariadb";
|
|
403
|
-
readonly host?: string;
|
|
404
|
-
readonly port?: number;
|
|
405
|
-
readonly username?: string;
|
|
406
|
-
readonly password?: string;
|
|
407
|
-
readonly database?: string;
|
|
408
|
-
readonly driverOptions?: MysqlCreateConnectionOptions;
|
|
409
|
-
}
|
|
410
|
-
interface NotNullableMysqlSqlDataSourceInput extends MysqlSqlDataSourceInput {
|
|
411
|
-
readonly type?: "mysql" | "mariadb";
|
|
412
|
-
readonly host: string;
|
|
413
|
-
readonly username: string;
|
|
414
|
-
readonly password: string;
|
|
415
|
-
readonly database: string;
|
|
416
|
-
readonly port?: number;
|
|
417
|
-
readonly driverOptions?: MysqlCreateConnectionOptions;
|
|
418
|
-
}
|
|
419
|
-
interface SqliteDataSourceInput extends CommonDataSourceInput {
|
|
420
|
-
readonly type?: "sqlite";
|
|
421
|
-
readonly database?: string;
|
|
422
|
-
}
|
|
423
|
-
interface NotNullableSqliteDataSourceInput extends SqliteDataSourceInput {
|
|
424
|
-
readonly type?: "sqlite";
|
|
425
|
-
readonly database: string;
|
|
426
|
-
}
|
|
427
|
-
/**
|
|
428
|
-
* @description By default the connection details can be provided in the .env file, you can still override each prop with your actual connection details in the input
|
|
429
|
-
*/
|
|
430
|
-
type DataSourceInput = MysqlSqlDataSourceInput | SqliteDataSourceInput | PostgresSqlDataSourceInput | MongoDataSourceInput;
|
|
431
|
-
|
|
432
429
|
declare abstract class DataSource {
|
|
433
430
|
type: DataSourceType;
|
|
434
431
|
host: string;
|
|
@@ -592,6 +589,12 @@ declare class Collection extends Entity {
|
|
|
592
589
|
* @returns {MongoQueryBuilder<T>}
|
|
593
590
|
*/
|
|
594
591
|
static query<T extends Collection>(this: new () => T | typeof Collection, options?: BaseModelMethodOptions$1): MongoQueryBuilder<T>;
|
|
592
|
+
/**
|
|
593
|
+
* @description Gets the raw collection from the mongoInstance using the underlying mongodb driver
|
|
594
|
+
* @param this
|
|
595
|
+
* @returns {DriverCollection<T>}
|
|
596
|
+
*/
|
|
597
|
+
static rawCollection<T extends typeof Collection>(this: T): Collection$1<Omit<InstanceType<T>, "$annotations" | "id">>;
|
|
595
598
|
/**
|
|
596
599
|
* @description Finds records in the collection, to use for simple queries
|
|
597
600
|
* @param this
|
|
@@ -1360,21 +1363,38 @@ declare class Schema {
|
|
|
1360
1363
|
private generateAstInstance;
|
|
1361
1364
|
}
|
|
1362
1365
|
|
|
1366
|
+
declare class FromNode extends QueryNode {
|
|
1367
|
+
table: string | QueryNode | QueryNode[];
|
|
1368
|
+
chainsWith: string;
|
|
1369
|
+
canKeywordBeSeenMultipleTimes: boolean;
|
|
1370
|
+
folder: string;
|
|
1371
|
+
file: string;
|
|
1372
|
+
alias?: string;
|
|
1373
|
+
constructor(table: string | QueryNode | QueryNode[], alias?: string);
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1363
1376
|
declare class InterpreterUtils {
|
|
1364
1377
|
private readonly model;
|
|
1365
1378
|
private readonly modelColumnsMap;
|
|
1366
1379
|
constructor(model: typeof Model);
|
|
1367
1380
|
formatStringColumn(dbType: SqlDataSourceType, column: string): string;
|
|
1381
|
+
/**
|
|
1382
|
+
* @description Formats the table name for the database type, idempotent for quoting
|
|
1383
|
+
*/
|
|
1368
1384
|
formatStringTable(dbType: SqlDataSourceType, table: string): string;
|
|
1369
1385
|
prepareColumns(columns: string[], values: any[], mode?: "insert" | "update"): {
|
|
1370
1386
|
columns: string[];
|
|
1371
1387
|
values: any[];
|
|
1372
1388
|
};
|
|
1389
|
+
/**
|
|
1390
|
+
* @description Formats the from node for write operations removing the "from" keyword
|
|
1391
|
+
*/
|
|
1392
|
+
getFromForWriteOperations(dbType: SqlDataSourceType, fromNode: FromNode): string;
|
|
1373
1393
|
}
|
|
1374
1394
|
|
|
1375
|
-
type BaseValues$1 = string | number | boolean |
|
|
1376
|
-
type BinaryOperatorType$1 = "=" | "!=" | "<>" | ">" | "<" | ">=" | "<=" | "
|
|
1377
|
-
declare class
|
|
1395
|
+
type BaseValues$1 = string | number | boolean | null;
|
|
1396
|
+
type BinaryOperatorType$1 = "=" | "!=" | "<>" | ">" | "<" | ">=" | "<=" | "like" | "ilike" | "in";
|
|
1397
|
+
declare class HavingNode extends QueryNode {
|
|
1378
1398
|
column: string;
|
|
1379
1399
|
isNegated: boolean;
|
|
1380
1400
|
operator: BinaryOperatorType$1;
|
|
@@ -1386,6 +1406,20 @@ declare class WhereNode extends QueryNode {
|
|
|
1386
1406
|
constructor(column: string, chainsWith: "and" | "or", isNegated: boolean | undefined, operator: BinaryOperatorType$1, value: BaseValues$1 | BaseValues$1[], isRawValue?: boolean);
|
|
1387
1407
|
}
|
|
1388
1408
|
|
|
1409
|
+
type BaseValues = string | number | boolean | undefined | null | RawNode;
|
|
1410
|
+
type BinaryOperatorType = "=" | "!=" | "<>" | ">" | "<" | ">=" | "<=" | "is" | "is not" | "like" | "not like" | "is null" | "is not null" | "ilike" | "in" | "not in" | "between" | "not between" | "regexp" | "not regexp" | "not ilike";
|
|
1411
|
+
declare class WhereNode extends QueryNode {
|
|
1412
|
+
column: string;
|
|
1413
|
+
isNegated: boolean;
|
|
1414
|
+
operator: BinaryOperatorType;
|
|
1415
|
+
value: BaseValues | BaseValues[];
|
|
1416
|
+
chainsWith: "and" | "or";
|
|
1417
|
+
canKeywordBeSeenMultipleTimes: boolean;
|
|
1418
|
+
folder: string;
|
|
1419
|
+
file: string;
|
|
1420
|
+
constructor(column: string, chainsWith: "and" | "or", isNegated: boolean | undefined, operator: BinaryOperatorType, value: BaseValues | BaseValues[], isRawValue?: boolean);
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1389
1423
|
type SubqueryOperatorType = "in" | "not in" | "exists" | "not exists" | "between" | "not between" | ">" | "<" | ">=" | "<=";
|
|
1390
1424
|
declare class WhereSubqueryNode extends QueryNode {
|
|
1391
1425
|
column: string;
|
|
@@ -1407,86 +1441,6 @@ declare class WhereGroupNode extends QueryNode {
|
|
|
1407
1441
|
constructor(nodes: (WhereNode | WhereGroupNode | WhereSubqueryNode)[], chainsWith?: "and" | "or");
|
|
1408
1442
|
}
|
|
1409
1443
|
|
|
1410
|
-
/**
|
|
1411
|
-
* @description Options for the relation
|
|
1412
|
-
* @property {string} softDeleteColumn - The column name for the soft delete column, if set, the relation will only return rows that have not been soft deleted
|
|
1413
|
-
* @property {string} softDeleteType - The type of the soft delete column
|
|
1414
|
-
*/
|
|
1415
|
-
declare enum RelationEnum {
|
|
1416
|
-
hasOne = "hasOne",// One to One without foreign key
|
|
1417
|
-
belongsTo = "belongsTo",// One to One with foreign key
|
|
1418
|
-
hasMany = "hasMany",
|
|
1419
|
-
manyToMany = "manyToMany"
|
|
1420
|
-
}
|
|
1421
|
-
/**
|
|
1422
|
-
* Main Relation Class
|
|
1423
|
-
*/
|
|
1424
|
-
declare abstract class Relation {
|
|
1425
|
-
abstract type: RelationEnum;
|
|
1426
|
-
model: typeof Model;
|
|
1427
|
-
columnName: string;
|
|
1428
|
-
foreignKey?: string;
|
|
1429
|
-
relatedModel: string;
|
|
1430
|
-
protected constructor(model: typeof Model, columnName: string);
|
|
1431
|
-
}
|
|
1432
|
-
|
|
1433
|
-
declare class SqlModelManagerUtils<T extends Model> {
|
|
1434
|
-
protected dbType: SqlDataSourceType;
|
|
1435
|
-
protected sqlDataSource: SqlDataSource;
|
|
1436
|
-
protected modelRelations: Relation[];
|
|
1437
|
-
protected modelRelationsMap: Map<string, Relation>;
|
|
1438
|
-
constructor(typeofModel: typeof Model, dbType: SqlDataSourceType, sqlDataSource: SqlDataSource);
|
|
1439
|
-
getRelationFromModel(relation: ModelRelation<T>): Relation;
|
|
1440
|
-
}
|
|
1441
|
-
|
|
1442
|
-
type PaginationMetadata = {
|
|
1443
|
-
perPage: number;
|
|
1444
|
-
currentPage: number;
|
|
1445
|
-
firstPage: number;
|
|
1446
|
-
isEmpty: boolean;
|
|
1447
|
-
total: number;
|
|
1448
|
-
lastPage: number;
|
|
1449
|
-
hasMorePages: boolean;
|
|
1450
|
-
hasPages: boolean;
|
|
1451
|
-
};
|
|
1452
|
-
type CursorPaginationMetadata = {
|
|
1453
|
-
perPage: number;
|
|
1454
|
-
firstPage: number;
|
|
1455
|
-
isEmpty: boolean;
|
|
1456
|
-
total: number;
|
|
1457
|
-
};
|
|
1458
|
-
type PaginatedData<T extends Model, A extends object = {}, R extends object = {}> = {
|
|
1459
|
-
paginationMetadata: PaginationMetadata;
|
|
1460
|
-
data: AnnotatedModel<T, A, R>[];
|
|
1461
|
-
};
|
|
1462
|
-
type CursorPaginatedData<T extends Model, A extends object = {}, R extends object = {}> = {
|
|
1463
|
-
paginationMetadata: CursorPaginationMetadata;
|
|
1464
|
-
data: AnnotatedModel<T, A, R>[];
|
|
1465
|
-
};
|
|
1466
|
-
|
|
1467
|
-
type DeleteOptions = {
|
|
1468
|
-
ignoreBeforeDeleteHook?: boolean;
|
|
1469
|
-
};
|
|
1470
|
-
type SoftDeleteOptions<T> = {
|
|
1471
|
-
column?: MongoCollectionKey<T>;
|
|
1472
|
-
value?: string | number | boolean;
|
|
1473
|
-
ignoreBeforeDeleteHook?: boolean;
|
|
1474
|
-
};
|
|
1475
|
-
|
|
1476
|
-
type BaseValues = string | number | boolean | null;
|
|
1477
|
-
type BinaryOperatorType = "=" | "!=" | "<>" | ">" | "<" | ">=" | "<=" | "like" | "ilike" | "in";
|
|
1478
|
-
declare class HavingNode extends QueryNode {
|
|
1479
|
-
column: string;
|
|
1480
|
-
isNegated: boolean;
|
|
1481
|
-
operator: BinaryOperatorType;
|
|
1482
|
-
value: BaseValues | BaseValues[];
|
|
1483
|
-
chainsWith: "and" | "or";
|
|
1484
|
-
canKeywordBeSeenMultipleTimes: boolean;
|
|
1485
|
-
folder: string;
|
|
1486
|
-
file: string;
|
|
1487
|
-
constructor(column: string, chainsWith: "and" | "or", isNegated: boolean | undefined, operator: BinaryOperatorType, value: BaseValues | BaseValues[], isRawValue?: boolean);
|
|
1488
|
-
}
|
|
1489
|
-
|
|
1490
1444
|
declare class DistinctNode extends QueryNode {
|
|
1491
1445
|
chainsWith: string;
|
|
1492
1446
|
canKeywordBeSeenMultipleTimes: boolean;
|
|
@@ -1504,16 +1458,6 @@ declare class DistinctOnNode extends QueryNode {
|
|
|
1504
1458
|
constructor(columns: string[]);
|
|
1505
1459
|
}
|
|
1506
1460
|
|
|
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
1461
|
declare class SelectNode extends QueryNode {
|
|
1518
1462
|
column: string | QueryNode | QueryNode[];
|
|
1519
1463
|
alias?: string;
|
|
@@ -1586,6 +1530,29 @@ declare class OrderByNode extends QueryNode {
|
|
|
1586
1530
|
type DateFormat = "ISO" | "TIMESTAMP" | "DATE_ONLY" | "TIME_ONLY";
|
|
1587
1531
|
type Timezone = "UTC" | "LOCAL";
|
|
1588
1532
|
|
|
1533
|
+
/**
|
|
1534
|
+
* @description Options for the relation
|
|
1535
|
+
* @property {string} softDeleteColumn - The column name for the soft delete column, if set, the relation will only return rows that have not been soft deleted
|
|
1536
|
+
* @property {string} softDeleteType - The type of the soft delete column
|
|
1537
|
+
*/
|
|
1538
|
+
declare enum RelationEnum {
|
|
1539
|
+
hasOne = "hasOne",// One to One without foreign key
|
|
1540
|
+
belongsTo = "belongsTo",// One to One with foreign key
|
|
1541
|
+
hasMany = "hasMany",
|
|
1542
|
+
manyToMany = "manyToMany"
|
|
1543
|
+
}
|
|
1544
|
+
/**
|
|
1545
|
+
* Main Relation Class
|
|
1546
|
+
*/
|
|
1547
|
+
declare abstract class Relation {
|
|
1548
|
+
abstract type: RelationEnum;
|
|
1549
|
+
model: typeof Model;
|
|
1550
|
+
columnName: string;
|
|
1551
|
+
foreignKey?: string;
|
|
1552
|
+
relatedModel: string;
|
|
1553
|
+
protected constructor(model: typeof Model, columnName: string);
|
|
1554
|
+
}
|
|
1555
|
+
|
|
1589
1556
|
type ColumnDataType = Exclude<keyof CreateTableBuilder, "enum" | "rawColumn" | "custom"> | readonly string[];
|
|
1590
1557
|
type ColumnDataTypeOptionWithLength = {
|
|
1591
1558
|
type?: "char" | "varchar" | "string" | "uuid" | "ulid" | "varbinary" | "integer" | "tinyint" | "smallint" | "mediumint" | "bigint";
|
|
@@ -1878,10 +1845,10 @@ declare abstract class JoinQueryBuilder<T extends Model> extends FooterQueryBuil
|
|
|
1878
1845
|
* @param primaryColumn - The primary column of the current model, default is caller model primary key if using a Model, if using a Raw Query Builder you must provide the key for the primary table, must be in the format of `table.column`
|
|
1879
1846
|
* @param operator - The comparison operator to use in the ON clause (default: "=")
|
|
1880
1847
|
*/
|
|
1881
|
-
innerJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, operator?: BinaryOperatorType
|
|
1882
|
-
innerJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn?: JoinableColumn, operator?: BinaryOperatorType
|
|
1883
|
-
innerJoin<R extends typeof Model>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, operator?: BinaryOperatorType
|
|
1884
|
-
innerJoin<R extends typeof Model>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn?: ModelKey<T>, operator?: BinaryOperatorType
|
|
1848
|
+
innerJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, operator?: BinaryOperatorType): this;
|
|
1849
|
+
innerJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn?: JoinableColumn, operator?: BinaryOperatorType): this;
|
|
1850
|
+
innerJoin<R extends typeof Model>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, operator?: BinaryOperatorType): this;
|
|
1851
|
+
innerJoin<R extends typeof Model>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn?: ModelKey<T>, operator?: BinaryOperatorType): this;
|
|
1885
1852
|
/**
|
|
1886
1853
|
* @description Join a table with the current model
|
|
1887
1854
|
* @param relationTable - The table to join
|
|
@@ -1889,10 +1856,10 @@ declare abstract class JoinQueryBuilder<T extends Model> extends FooterQueryBuil
|
|
|
1889
1856
|
* @param primaryColumn - The primary column of the current model, default is caller model primary key if using a Model, if using a Raw Query Builder you must provide the key for the primary table, must be in the format of `table.column`
|
|
1890
1857
|
* @param operator - The comparison operator to use in the ON clause (default: "=")
|
|
1891
1858
|
*/
|
|
1892
|
-
join(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, operator?: BinaryOperatorType
|
|
1893
|
-
join(relationTable: string, referencingColumn: JoinableColumn, primaryColumn?: JoinableColumn, operator?: BinaryOperatorType
|
|
1894
|
-
join<R extends typeof Model>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, operator?: BinaryOperatorType
|
|
1895
|
-
join<R extends typeof Model>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn?: ModelKey<T>, operator?: BinaryOperatorType
|
|
1859
|
+
join(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, operator?: BinaryOperatorType): this;
|
|
1860
|
+
join(relationTable: string, referencingColumn: JoinableColumn, primaryColumn?: JoinableColumn, operator?: BinaryOperatorType): this;
|
|
1861
|
+
join<R extends typeof Model>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, operator?: BinaryOperatorType): this;
|
|
1862
|
+
join<R extends typeof Model>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn?: ModelKey<T>, operator?: BinaryOperatorType): this;
|
|
1896
1863
|
/**
|
|
1897
1864
|
* @description Join a table with the current model
|
|
1898
1865
|
* @param relationTable - The table to join
|
|
@@ -1900,10 +1867,10 @@ declare abstract class JoinQueryBuilder<T extends Model> extends FooterQueryBuil
|
|
|
1900
1867
|
* @param primaryColumn - The primary column of the current model, default is caller model primary key if using a Model, if using a Raw Query Builder you must provide the key for the primary table, must be in the format of `table.column`
|
|
1901
1868
|
* @param operator - The comparison operator to use in the ON clause (default: "=")
|
|
1902
1869
|
*/
|
|
1903
|
-
leftJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, operator?: BinaryOperatorType
|
|
1904
|
-
leftJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn?: JoinableColumn, operator?: BinaryOperatorType
|
|
1905
|
-
leftJoin<R extends typeof Model>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, operator?: BinaryOperatorType
|
|
1906
|
-
leftJoin<R extends typeof Model>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn?: ModelKey<T>, operator?: BinaryOperatorType
|
|
1870
|
+
leftJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, operator?: BinaryOperatorType): this;
|
|
1871
|
+
leftJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn?: JoinableColumn, operator?: BinaryOperatorType): this;
|
|
1872
|
+
leftJoin<R extends typeof Model>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, operator?: BinaryOperatorType): this;
|
|
1873
|
+
leftJoin<R extends typeof Model>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn?: ModelKey<T>, operator?: BinaryOperatorType): this;
|
|
1907
1874
|
/**
|
|
1908
1875
|
* @description Join a table with the current model
|
|
1909
1876
|
* @param relationTable - The table to join
|
|
@@ -1911,8 +1878,8 @@ declare abstract class JoinQueryBuilder<T extends Model> extends FooterQueryBuil
|
|
|
1911
1878
|
* @param primaryColumn - The primary column of the current model, default is caller model primary key if using A Model, if using a Raw Query Builder you must provide the key for the primary table
|
|
1912
1879
|
* @param operator - The comparison operator to use in the ON clause (default: "=")
|
|
1913
1880
|
*/
|
|
1914
|
-
rightJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn: JoinableColumn, operator?: BinaryOperatorType
|
|
1915
|
-
rightJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn?: JoinableColumn, operator?: BinaryOperatorType
|
|
1881
|
+
rightJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn: JoinableColumn, operator?: BinaryOperatorType): this;
|
|
1882
|
+
rightJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn?: JoinableColumn, operator?: BinaryOperatorType): this;
|
|
1916
1883
|
/**
|
|
1917
1884
|
* @description Perform a FULL OUTER JOIN with another table
|
|
1918
1885
|
* @param relationTable - The table to join
|
|
@@ -1920,8 +1887,8 @@ declare abstract class JoinQueryBuilder<T extends Model> extends FooterQueryBuil
|
|
|
1920
1887
|
* @param primaryColumn - The primary column of the current model
|
|
1921
1888
|
* @param operator - The comparison operator to use in the ON clause (default: "=")
|
|
1922
1889
|
*/
|
|
1923
|
-
fullJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn: JoinableColumn, operator?: BinaryOperatorType
|
|
1924
|
-
fullJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn?: JoinableColumn, operator?: BinaryOperatorType
|
|
1890
|
+
fullJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn: JoinableColumn, operator?: BinaryOperatorType): this;
|
|
1891
|
+
fullJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn?: JoinableColumn, operator?: BinaryOperatorType): this;
|
|
1925
1892
|
}
|
|
1926
1893
|
|
|
1927
1894
|
declare class SelectQueryBuilder<T extends Model> extends JoinQueryBuilder<T> {
|
|
@@ -1983,8 +1950,9 @@ declare class SelectQueryBuilder<T extends Model> extends JoinQueryBuilder<T> {
|
|
|
1983
1950
|
/**
|
|
1984
1951
|
* @description Sets the table to select from, by default is the table defined in the Model
|
|
1985
1952
|
* @description Can be used on non select queries too, it will only specify the table name (es. INSERT INTO $table)
|
|
1953
|
+
* @param table The table name to query from, must be in valid sql format `table` or `table as alias`
|
|
1986
1954
|
*/
|
|
1987
|
-
from(table:
|
|
1955
|
+
from<S extends string>(table: TableFormat<S>): this;
|
|
1988
1956
|
/**
|
|
1989
1957
|
* @description Sets the table to select from, by default is the table defined in the Model
|
|
1990
1958
|
* @description Better naming convention for non select queries
|
|
@@ -2024,84 +1992,84 @@ declare abstract class WhereQueryBuilder<T extends Model> extends SelectQueryBui
|
|
|
2024
1992
|
/**
|
|
2025
1993
|
* @description Adds a WHERE condition to the query.
|
|
2026
1994
|
*/
|
|
2027
|
-
where(column: ModelKey<T>, operator: BinaryOperatorType
|
|
2028
|
-
where<S extends string>(column: SelectableColumn<S>, operator: BinaryOperatorType
|
|
1995
|
+
where(column: ModelKey<T>, operator: BinaryOperatorType, value: BaseValues): this;
|
|
1996
|
+
where<S extends string>(column: SelectableColumn<S>, operator: BinaryOperatorType, value: BaseValues): this;
|
|
2029
1997
|
where(cb: (queryBuilder: WhereOnlyQueryBuilder<T>) => void): this;
|
|
2030
1998
|
where(column: ModelKey<T> | SelectableColumn<string>, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
|
|
2031
1999
|
where(column: ModelKey<T> | SelectableColumn<string>, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
|
|
2032
|
-
where(column: ModelKey<T> | SelectableColumn<string>, value: BaseValues
|
|
2000
|
+
where(column: ModelKey<T> | SelectableColumn<string>, value: BaseValues): this;
|
|
2033
2001
|
/**
|
|
2034
2002
|
* @description Adds an AND WHERE condition to the query.
|
|
2035
2003
|
*/
|
|
2036
|
-
andWhere(column: ModelKey<T>, operator: BinaryOperatorType
|
|
2037
|
-
andWhere(column: SelectableColumn<string>, operator: BinaryOperatorType
|
|
2038
|
-
andWhere(column: ModelKey<T> | SelectableColumn<string>, value: BaseValues
|
|
2004
|
+
andWhere(column: ModelKey<T>, operator: BinaryOperatorType, value: BaseValues): this;
|
|
2005
|
+
andWhere(column: SelectableColumn<string>, operator: BinaryOperatorType, value: BaseValues): this;
|
|
2006
|
+
andWhere(column: ModelKey<T> | SelectableColumn<string>, value: BaseValues): this;
|
|
2039
2007
|
andWhere(cb: (queryBuilder: WhereOnlyQueryBuilder<T>) => void): this;
|
|
2040
2008
|
andWhere(column: ModelKey<T> | SelectableColumn<string>, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
|
|
2041
2009
|
andWhere(column: ModelKey<T> | SelectableColumn<string>, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
|
|
2042
2010
|
/**
|
|
2043
2011
|
* @description Adds an OR WHERE condition to the query.
|
|
2044
2012
|
*/
|
|
2045
|
-
orWhere(column: ModelKey<T>, operator: BinaryOperatorType
|
|
2046
|
-
orWhere<S extends string>(column: SelectableColumn<S>, operator: BinaryOperatorType
|
|
2047
|
-
orWhere<S extends string>(column: ModelKey<T> | SelectableColumn<S>, value: BaseValues
|
|
2013
|
+
orWhere(column: ModelKey<T>, operator: BinaryOperatorType, value: BaseValues): this;
|
|
2014
|
+
orWhere<S extends string>(column: SelectableColumn<S>, operator: BinaryOperatorType, value: BaseValues): this;
|
|
2015
|
+
orWhere<S extends string>(column: ModelKey<T> | SelectableColumn<S>, value: BaseValues): this;
|
|
2048
2016
|
orWhere(cb: (queryBuilder: WhereOnlyQueryBuilder<T>) => void): this;
|
|
2049
2017
|
orWhere(column: ModelKey<T> | SelectableColumn<string>, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
|
|
2050
2018
|
orWhere(column: ModelKey<T> | SelectableColumn<string>, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
|
|
2051
2019
|
/**
|
|
2052
2020
|
* @description Adds a negated WHERE condition to the query.
|
|
2053
2021
|
*/
|
|
2054
|
-
whereNot(column: ModelKey<T>, operator: BinaryOperatorType
|
|
2055
|
-
whereNot<S extends string>(column: SelectableColumn<S>, operator: BinaryOperatorType
|
|
2056
|
-
whereNot(column: ModelKey<T> | SelectableColumn<string>, value: BaseValues
|
|
2022
|
+
whereNot(column: ModelKey<T>, operator: BinaryOperatorType, value: BaseValues): this;
|
|
2023
|
+
whereNot<S extends string>(column: SelectableColumn<S>, operator: BinaryOperatorType, value: BaseValues): this;
|
|
2024
|
+
whereNot(column: ModelKey<T> | SelectableColumn<string>, value: BaseValues): this;
|
|
2057
2025
|
whereNot(column: ModelKey<T> | SelectableColumn<string>, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
|
|
2058
2026
|
whereNot(column: ModelKey<T> | SelectableColumn<string>, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
|
|
2059
2027
|
/**
|
|
2060
2028
|
* @description Adds a negated AND WHERE condition to the query.
|
|
2061
2029
|
*/
|
|
2062
|
-
andWhereNot(column: ModelKey<T>, operator: BinaryOperatorType
|
|
2063
|
-
andWhereNot<S extends string>(column: SelectableColumn<S>, operator: BinaryOperatorType
|
|
2064
|
-
andWhereNot(column: ModelKey<T> | SelectableColumn<string>, value: BaseValues
|
|
2030
|
+
andWhereNot(column: ModelKey<T>, operator: BinaryOperatorType, value: BaseValues): this;
|
|
2031
|
+
andWhereNot<S extends string>(column: SelectableColumn<S>, operator: BinaryOperatorType, value: BaseValues): this;
|
|
2032
|
+
andWhereNot(column: ModelKey<T> | SelectableColumn<string>, value: BaseValues): this;
|
|
2065
2033
|
andWhereNot(column: ModelKey<T> | SelectableColumn<string>, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
|
|
2066
2034
|
andWhereNot(column: ModelKey<T> | SelectableColumn<string>, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
|
|
2067
2035
|
/**
|
|
2068
2036
|
* @description Adds a negated OR WHERE condition to the query.
|
|
2069
2037
|
*/
|
|
2070
|
-
orWhereNot(column: ModelKey<T>, operator: BinaryOperatorType
|
|
2071
|
-
orWhereNot<S extends string>(column: SelectableColumn<S>, operator: BinaryOperatorType
|
|
2072
|
-
orWhereNot(column: ModelKey<T> | SelectableColumn<string>, value: BaseValues
|
|
2038
|
+
orWhereNot(column: ModelKey<T>, operator: BinaryOperatorType, value: BaseValues): this;
|
|
2039
|
+
orWhereNot<S extends string>(column: SelectableColumn<S>, operator: BinaryOperatorType, value: BaseValues): this;
|
|
2040
|
+
orWhereNot(column: ModelKey<T> | SelectableColumn<string>, value: BaseValues): this;
|
|
2073
2041
|
orWhereNot(column: ModelKey<T> | SelectableColumn<string>, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
|
|
2074
2042
|
orWhereNot(column: ModelKey<T> | SelectableColumn<string>, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
|
|
2075
2043
|
/**
|
|
2076
2044
|
* @description Adds a WHERE BETWEEN condition to the query.
|
|
2077
2045
|
*/
|
|
2078
|
-
whereBetween(column: ModelKey<T>, min: BaseValues
|
|
2079
|
-
whereBetween<S extends string>(column: SelectableColumn<S>, min: BaseValues
|
|
2046
|
+
whereBetween(column: ModelKey<T>, min: BaseValues, max: BaseValues): this;
|
|
2047
|
+
whereBetween<S extends string>(column: SelectableColumn<S>, min: BaseValues, max: BaseValues): this;
|
|
2080
2048
|
/**
|
|
2081
2049
|
* @description Adds an AND WHERE BETWEEN condition to the query.
|
|
2082
2050
|
*/
|
|
2083
|
-
andWhereBetween(column: ModelKey<T>, min: BaseValues
|
|
2084
|
-
andWhereBetween<S extends string>(column: SelectableColumn<S>, min: BaseValues
|
|
2051
|
+
andWhereBetween(column: ModelKey<T>, min: BaseValues, max: BaseValues): this;
|
|
2052
|
+
andWhereBetween<S extends string>(column: SelectableColumn<S>, min: BaseValues, max: BaseValues): this;
|
|
2085
2053
|
/**
|
|
2086
2054
|
* @description Adds an OR WHERE BETWEEN condition to the query.
|
|
2087
2055
|
*/
|
|
2088
|
-
orWhereBetween(column: ModelKey<T>, min: BaseValues
|
|
2089
|
-
orWhereBetween<S extends string>(column: SelectableColumn<S>, min: BaseValues
|
|
2056
|
+
orWhereBetween(column: ModelKey<T>, min: BaseValues, max: BaseValues): this;
|
|
2057
|
+
orWhereBetween<S extends string>(column: SelectableColumn<S>, min: BaseValues, max: BaseValues): this;
|
|
2090
2058
|
/**
|
|
2091
2059
|
* @description Adds a WHERE NOT BETWEEN condition to the query.
|
|
2092
2060
|
*/
|
|
2093
|
-
whereNotBetween(column: ModelKey<T>, min: BaseValues
|
|
2094
|
-
whereNotBetween<S extends string>(column: SelectableColumn<S>, min: BaseValues
|
|
2061
|
+
whereNotBetween(column: ModelKey<T>, min: BaseValues, max: BaseValues): this;
|
|
2062
|
+
whereNotBetween<S extends string>(column: SelectableColumn<S>, min: BaseValues, max: BaseValues): this;
|
|
2095
2063
|
/**
|
|
2096
2064
|
* @description Adds an AND WHERE NOT BETWEEN condition to the query.
|
|
2097
2065
|
*/
|
|
2098
|
-
andWhereNotBetween(column: ModelKey<T>, min: BaseValues
|
|
2099
|
-
andWhereNotBetween<S extends string>(column: SelectableColumn<S>, min: BaseValues
|
|
2066
|
+
andWhereNotBetween(column: ModelKey<T>, min: BaseValues, max: BaseValues): this;
|
|
2067
|
+
andWhereNotBetween<S extends string>(column: SelectableColumn<S>, min: BaseValues, max: BaseValues): this;
|
|
2100
2068
|
/**
|
|
2101
2069
|
* @description Adds an OR WHERE NOT BETWEEN condition to the query.
|
|
2102
2070
|
*/
|
|
2103
|
-
orWhereNotBetween(column: ModelKey<T>, min: BaseValues
|
|
2104
|
-
orWhereNotBetween<S extends string>(column: SelectableColumn<S>, min: BaseValues
|
|
2071
|
+
orWhereNotBetween(column: ModelKey<T>, min: BaseValues, max: BaseValues): this;
|
|
2072
|
+
orWhereNotBetween<S extends string>(column: SelectableColumn<S>, min: BaseValues, max: BaseValues): this;
|
|
2105
2073
|
/**
|
|
2106
2074
|
* @description Adds a WHERE LIKE condition to the query.
|
|
2107
2075
|
*/
|
|
@@ -2166,38 +2134,38 @@ declare abstract class WhereQueryBuilder<T extends Model> extends SelectQueryBui
|
|
|
2166
2134
|
* @description Adds a WHERE IN condition to the query.
|
|
2167
2135
|
* @warning If the array is empty, it will add an impossible condition.
|
|
2168
2136
|
*/
|
|
2169
|
-
whereIn(column: ModelKey<T>, values: BaseValues
|
|
2170
|
-
whereIn<S extends string>(column: SelectableColumn<S>, values: BaseValues
|
|
2137
|
+
whereIn(column: ModelKey<T>, values: BaseValues[]): this;
|
|
2138
|
+
whereIn<S extends string>(column: SelectableColumn<S>, values: BaseValues[]): this;
|
|
2171
2139
|
/**
|
|
2172
2140
|
* @description Adds an AND WHERE IN condition to the query.
|
|
2173
2141
|
* @warning If the array is empty, it will add an impossible condition.
|
|
2174
2142
|
*/
|
|
2175
|
-
andWhereIn(column: ModelKey<T>, values: BaseValues
|
|
2176
|
-
andWhereIn<S extends string>(column: SelectableColumn<S>, values: BaseValues
|
|
2143
|
+
andWhereIn(column: ModelKey<T>, values: BaseValues[]): this;
|
|
2144
|
+
andWhereIn<S extends string>(column: SelectableColumn<S>, values: BaseValues[]): this;
|
|
2177
2145
|
/**
|
|
2178
2146
|
* @description Adds an OR WHERE IN condition to the query.
|
|
2179
2147
|
* @warning If the array is empty, it will add an impossible condition.
|
|
2180
2148
|
*/
|
|
2181
|
-
orWhereIn(column: ModelKey<T>, values: BaseValues
|
|
2182
|
-
orWhereIn<S extends string>(column: SelectableColumn<S>, values: BaseValues
|
|
2149
|
+
orWhereIn(column: ModelKey<T>, values: BaseValues[]): this;
|
|
2150
|
+
orWhereIn<S extends string>(column: SelectableColumn<S>, values: BaseValues[]): this;
|
|
2183
2151
|
/**
|
|
2184
2152
|
* @description Adds a WHERE NOT IN condition to the query.
|
|
2185
2153
|
* @warning If the array is empty, it will add an obvious condition to make it true.
|
|
2186
2154
|
*/
|
|
2187
|
-
whereNotIn(column: ModelKey<T>, values: BaseValues
|
|
2188
|
-
whereNotIn<S extends string>(column: SelectableColumn<S>, values: BaseValues
|
|
2155
|
+
whereNotIn(column: ModelKey<T>, values: BaseValues[]): this;
|
|
2156
|
+
whereNotIn<S extends string>(column: SelectableColumn<S>, values: BaseValues[]): this;
|
|
2189
2157
|
/**
|
|
2190
2158
|
* @description Adds an OR WHERE NOT IN condition to the query.
|
|
2191
2159
|
* @warning If the array is empty, it will add an obvious condition to make it true.
|
|
2192
2160
|
*/
|
|
2193
|
-
andWhereNotIn(column: ModelKey<T>, values: BaseValues
|
|
2194
|
-
andWhereNotIn<S extends string>(column: SelectableColumn<S>, values: BaseValues
|
|
2161
|
+
andWhereNotIn(column: ModelKey<T>, values: BaseValues[]): this;
|
|
2162
|
+
andWhereNotIn<S extends string>(column: SelectableColumn<S>, values: BaseValues[]): this;
|
|
2195
2163
|
/**
|
|
2196
2164
|
* @description Adds an OR WHERE NOT IN condition to the query.
|
|
2197
2165
|
* @warning If the array is empty, it will add an obvious condition to make it true.
|
|
2198
2166
|
*/
|
|
2199
|
-
orWhereNotIn(column: ModelKey<T>, values: BaseValues
|
|
2200
|
-
orWhereNotIn<S extends string>(column: SelectableColumn<S>, values: BaseValues
|
|
2167
|
+
orWhereNotIn(column: ModelKey<T>, values: BaseValues[]): this;
|
|
2168
|
+
orWhereNotIn<S extends string>(column: SelectableColumn<S>, values: BaseValues[]): this;
|
|
2201
2169
|
/**
|
|
2202
2170
|
* @description Adds a WHERE NULL condition to the query.
|
|
2203
2171
|
*/
|
|
@@ -2289,17 +2257,17 @@ declare abstract class WhereQueryBuilder<T extends Model> extends SelectQueryBui
|
|
|
2289
2257
|
* @description Adds a HAVING condition to the query.
|
|
2290
2258
|
*/
|
|
2291
2259
|
having<S extends string>(column: SelectableColumn<S>, value: any): this;
|
|
2292
|
-
having(column: ModelKey<T>, operator: BinaryOperatorType
|
|
2260
|
+
having(column: ModelKey<T>, operator: BinaryOperatorType, value: any): this;
|
|
2293
2261
|
/**
|
|
2294
2262
|
* @description Adds an AND HAVING condition to the query.
|
|
2295
2263
|
*/
|
|
2296
2264
|
andHaving<S extends string>(column: SelectableColumn<S>, value: any): this;
|
|
2297
|
-
andHaving(column: ModelKey<T>, operator: BinaryOperatorType
|
|
2265
|
+
andHaving(column: ModelKey<T>, operator: BinaryOperatorType, value: any): this;
|
|
2298
2266
|
/**
|
|
2299
2267
|
* @description Adds an OR HAVING condition to the query.
|
|
2300
2268
|
*/
|
|
2301
2269
|
orHaving<S extends string>(column: SelectableColumn<S>, value: any): this;
|
|
2302
|
-
orHaving(column: ModelKey<T>, operator: BinaryOperatorType
|
|
2270
|
+
orHaving(column: ModelKey<T>, operator: BinaryOperatorType, value: any): this;
|
|
2303
2271
|
/**
|
|
2304
2272
|
* @description Adds a raw HAVING condition to the query.
|
|
2305
2273
|
*/
|
|
@@ -2434,6 +2402,49 @@ type PaginateWithCursorOptions<T extends Model, K extends ModelKey<T>> = {
|
|
|
2434
2402
|
orderBy?: "asc" | "desc";
|
|
2435
2403
|
};
|
|
2436
2404
|
|
|
2405
|
+
declare class SqlModelManagerUtils<T extends Model> {
|
|
2406
|
+
protected dbType: SqlDataSourceType;
|
|
2407
|
+
protected sqlDataSource: SqlDataSource;
|
|
2408
|
+
protected modelRelations: Relation[];
|
|
2409
|
+
protected modelRelationsMap: Map<string, Relation>;
|
|
2410
|
+
constructor(typeofModel: typeof Model, dbType: SqlDataSourceType, sqlDataSource: SqlDataSource);
|
|
2411
|
+
getRelationFromModel(relation: ModelRelation<T>): Relation;
|
|
2412
|
+
}
|
|
2413
|
+
|
|
2414
|
+
type PaginationMetadata = {
|
|
2415
|
+
perPage: number;
|
|
2416
|
+
currentPage: number;
|
|
2417
|
+
firstPage: number;
|
|
2418
|
+
isEmpty: boolean;
|
|
2419
|
+
total: number;
|
|
2420
|
+
lastPage: number;
|
|
2421
|
+
hasMorePages: boolean;
|
|
2422
|
+
hasPages: boolean;
|
|
2423
|
+
};
|
|
2424
|
+
type CursorPaginationMetadata = {
|
|
2425
|
+
perPage: number;
|
|
2426
|
+
firstPage: number;
|
|
2427
|
+
isEmpty: boolean;
|
|
2428
|
+
total: number;
|
|
2429
|
+
};
|
|
2430
|
+
type PaginatedData<T extends Model, A extends object = {}, R extends object = {}> = {
|
|
2431
|
+
paginationMetadata: PaginationMetadata;
|
|
2432
|
+
data: AnnotatedModel<T, A, R>[];
|
|
2433
|
+
};
|
|
2434
|
+
type CursorPaginatedData<T extends Model, A extends object = {}, R extends object = {}> = {
|
|
2435
|
+
paginationMetadata: CursorPaginationMetadata;
|
|
2436
|
+
data: AnnotatedModel<T, A, R>[];
|
|
2437
|
+
};
|
|
2438
|
+
|
|
2439
|
+
type DeleteOptions = {
|
|
2440
|
+
ignoreBeforeDeleteHook?: boolean;
|
|
2441
|
+
};
|
|
2442
|
+
type SoftDeleteOptions<T> = {
|
|
2443
|
+
column?: MongoCollectionKey<T>;
|
|
2444
|
+
value?: string | number | boolean;
|
|
2445
|
+
ignoreBeforeDeleteHook?: boolean;
|
|
2446
|
+
};
|
|
2447
|
+
|
|
2437
2448
|
type UpdateOptions = {
|
|
2438
2449
|
ignoreBeforeUpdateHook?: boolean;
|
|
2439
2450
|
};
|
|
@@ -2546,15 +2557,36 @@ type BaseModelMethodOptions = {
|
|
|
2546
2557
|
* const user = await User.query({ connection: customConnection }).first();
|
|
2547
2558
|
* ```
|
|
2548
2559
|
*/
|
|
2549
|
-
connection?: SqlDataSource | AugmentedSqlDataSource;
|
|
2560
|
+
connection?: SqlDataSource | AugmentedSqlDataSource;
|
|
2561
|
+
/**
|
|
2562
|
+
* @description The transaction instance to use for the model
|
|
2563
|
+
*/
|
|
2564
|
+
trx?: Transaction;
|
|
2565
|
+
/**
|
|
2566
|
+
* @description Whether to ignore the hooks for the model
|
|
2567
|
+
*/
|
|
2568
|
+
ignoreHooks?: boolean;
|
|
2569
|
+
};
|
|
2570
|
+
/**
|
|
2571
|
+
* @description Options that can be provided to a raw sql operation (like the raw QueryBuilder)
|
|
2572
|
+
*/
|
|
2573
|
+
type RawModelOptions = {
|
|
2574
|
+
/**
|
|
2575
|
+
* Alias for the table
|
|
2576
|
+
*/
|
|
2577
|
+
alias?: string;
|
|
2550
2578
|
/**
|
|
2551
|
-
* @description
|
|
2579
|
+
* @description Convert the column casing before making a Database query, by default preserves what is provided
|
|
2552
2580
|
*/
|
|
2553
|
-
|
|
2581
|
+
databaseCaseConvention?: CaseConvention;
|
|
2554
2582
|
/**
|
|
2555
|
-
*
|
|
2583
|
+
* Column to use for soft deleted, by default is `deleted_at`
|
|
2556
2584
|
*/
|
|
2557
|
-
|
|
2585
|
+
softDeleteColumn?: string;
|
|
2586
|
+
/**
|
|
2587
|
+
* Column to use for soft deleted, by default is date in format: "YYYY-MM-DD HH:mm:ss" in UTC timezone
|
|
2588
|
+
*/
|
|
2589
|
+
softDeleteValue?: string | boolean;
|
|
2558
2590
|
};
|
|
2559
2591
|
|
|
2560
2592
|
/**
|
|
@@ -2606,6 +2638,26 @@ declare class ModelQueryBuilder<T extends Model, A extends Record<string, any> =
|
|
|
2606
2638
|
data: [CursorPaginatedData<T, A, R>, Cursor<T, ModelKey<T>>];
|
|
2607
2639
|
time: number;
|
|
2608
2640
|
}>;
|
|
2641
|
+
truncate: (returnType?: "millis" | "seconds") => Promise<{
|
|
2642
|
+
data: void;
|
|
2643
|
+
time: number;
|
|
2644
|
+
}>;
|
|
2645
|
+
delete: (returnType?: "millis" | "seconds") => Promise<{
|
|
2646
|
+
data: number;
|
|
2647
|
+
time: number;
|
|
2648
|
+
}>;
|
|
2649
|
+
update: (data: Partial<ModelWithoutRelations<T>>, options?: UpdateOptions, returnType?: "millis" | "seconds") => Promise<{
|
|
2650
|
+
data: number;
|
|
2651
|
+
time: number;
|
|
2652
|
+
}>;
|
|
2653
|
+
softDelete: (options?: Omit<SoftDeleteOptions<T>, "ignoreBeforeDeleteHook">, returnType?: "millis" | "seconds") => Promise<{
|
|
2654
|
+
data: number;
|
|
2655
|
+
time: number;
|
|
2656
|
+
}>;
|
|
2657
|
+
pluck: (key: ModelKey<T>, returnType?: "millis" | "seconds") => Promise<{
|
|
2658
|
+
data: PluckReturnType<T, ModelKey<T>>;
|
|
2659
|
+
time: number;
|
|
2660
|
+
}>;
|
|
2609
2661
|
};
|
|
2610
2662
|
constructor(model: typeof Model, sqlDataSource: SqlDataSource);
|
|
2611
2663
|
/**
|
|
@@ -2631,15 +2683,16 @@ declare class ModelQueryBuilder<T extends Model, A extends Record<string, any> =
|
|
|
2631
2683
|
}): Promise<AnnotatedModel<T, A, R>>;
|
|
2632
2684
|
many(options?: ManyOptions): Promise<AnnotatedModel<T, A, R>[]>;
|
|
2633
2685
|
chunk(chunkSize: number, options?: ManyOptions): AsyncGenerator<AnnotatedModel<T, A, R>[]>;
|
|
2634
|
-
stream(options?: ManyOptions & StreamOptions
|
|
2686
|
+
stream(options?: ManyOptions & StreamOptions): 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
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2688
|
+
/**
|
|
2689
|
+
* @description Inserts a new record into the database, it is not advised to use this method directly from the query builder if using a ModelQueryBuilder (`Model.query()`), use the `Model.insert` method instead.
|
|
2690
|
+
*/
|
|
2691
|
+
insert(...args: Parameters<typeof this$1.model.insert>): ReturnType<typeof this$1.model.insert>;
|
|
2692
|
+
/**
|
|
2693
|
+
* @description Inserts multiple records into the database, it is not advised to use this method directly from the query builder if using a ModelQueryBuilder (`Model.query()`), use the `Model.insertMany` method instead.
|
|
2694
|
+
*/
|
|
2695
|
+
insertMany(...args: Parameters<typeof this$1.model.insertMany>): ReturnType<typeof this$1.model.insertMany>;
|
|
2643
2696
|
update(data: Partial<ModelWithoutRelations<T>>, options?: UpdateOptions): Promise<number>;
|
|
2644
2697
|
softDelete(options?: SoftDeleteOptions<T>): Promise<number>;
|
|
2645
2698
|
delete(options?: DeleteOptions): Promise<number>;
|
|
@@ -2709,37 +2762,37 @@ declare class ModelQueryBuilder<T extends Model, A extends Record<string, any> =
|
|
|
2709
2762
|
* @warning All select statements are ignored, since we're only checking if the relation exists, a "select 1" will be added to the Query
|
|
2710
2763
|
*/
|
|
2711
2764
|
havingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, cb?: (queryBuilder: ModelQueryBuilder<RelatedInstance<T, RelationKey>>) => void): this;
|
|
2712
|
-
havingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, operatorOrValue?: BinaryOperatorType
|
|
2765
|
+
havingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, operatorOrValue?: BinaryOperatorType | BaseValues, maybeValue?: BaseValues): this;
|
|
2713
2766
|
/**
|
|
2714
2767
|
* @description Checks if the relation exists in the models and has the given filters, if no callback is provided, it only check if there is at least one record for the relation
|
|
2715
2768
|
* @warning All select statements are ignored, since we're only checking if the relation exists, a "select 1" will be added to the Query
|
|
2716
2769
|
*/
|
|
2717
2770
|
andHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, cb?: (queryBuilder: ModelQueryBuilder<RelatedInstance<T, RelationKey>>) => void): this;
|
|
2718
|
-
andHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, operatorOrValue?: BinaryOperatorType
|
|
2771
|
+
andHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, operatorOrValue?: BinaryOperatorType | BaseValues, maybeValue?: BaseValues): this;
|
|
2719
2772
|
/**
|
|
2720
2773
|
* @description Checks if the relation exists in the models and has the given filters, if no callback is provided, it only check if there is at least one record for the relation,
|
|
2721
2774
|
* @warning All select statements are ignored, since we're only checking if the relation exists, a "select 1" will be added to the Query
|
|
2722
2775
|
*/
|
|
2723
2776
|
orHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, cb?: (queryBuilder: ModelQueryBuilder<RelatedInstance<T, RelationKey>>) => void): this;
|
|
2724
|
-
orHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, operatorOrValue?: BinaryOperatorType
|
|
2777
|
+
orHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, operatorOrValue?: BinaryOperatorType | BaseValues, maybeValue?: BaseValues): this;
|
|
2725
2778
|
/**
|
|
2726
2779
|
* @description Checks if the relation does not exist in the models and has the given filters, if no callback is provided, it only check if there is no record for the Relation
|
|
2727
2780
|
* @warning All select statements are ignored, since we're only checking if the relation exists, a "select 1" will be added to the Query
|
|
2728
2781
|
*/
|
|
2729
2782
|
notHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, cb?: (queryBuilder: ModelQueryBuilder<RelatedInstance<T, RelationKey>>) => void): this;
|
|
2730
|
-
notHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, operatorOrValue?: BinaryOperatorType
|
|
2783
|
+
notHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, operatorOrValue?: BinaryOperatorType | BaseValues, maybeValue?: BaseValues): this;
|
|
2731
2784
|
/**
|
|
2732
2785
|
* @description Checks if the relation does not exist in the models and has the given filters, if no callback is provided, it only check if there is no record for the relation
|
|
2733
2786
|
* @warning All select statements are ignored, since we're only checking if the relation exists, a "select 1" will be added to the Query
|
|
2734
2787
|
*/
|
|
2735
2788
|
andNotHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, cb?: (queryBuilder: ModelQueryBuilder<RelatedInstance<T, RelationKey>>) => void): this;
|
|
2736
|
-
andNotHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, operatorOrValue?: BinaryOperatorType
|
|
2789
|
+
andNotHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, operatorOrValue?: BinaryOperatorType | BaseValues, maybeValue?: BaseValues): this;
|
|
2737
2790
|
/**
|
|
2738
2791
|
* @description Checks if the relation does not exist in the models and has the given filters, if no callback is provided, it only check if there is no record for the Relation
|
|
2739
2792
|
* @warning All select statements are ignored, since we're only checking if the relation exists, a "select 1" will be added to the Query
|
|
2740
2793
|
*/
|
|
2741
2794
|
orNotHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, cb?: (queryBuilder: ModelQueryBuilder<RelatedInstance<T, RelationKey>>) => void): this;
|
|
2742
|
-
orNotHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, operatorOrValue?: BinaryOperatorType
|
|
2795
|
+
orNotHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, operatorOrValue?: BinaryOperatorType | BaseValues, maybeValue?: BaseValues): this;
|
|
2743
2796
|
/**
|
|
2744
2797
|
* @description Returns a copy of the query builder instance.
|
|
2745
2798
|
*/
|
|
@@ -2752,8 +2805,21 @@ declare class ModelQueryBuilder<T extends Model, A extends Record<string, any> =
|
|
|
2752
2805
|
protected getRelatedModelsForRelation(relationQueryBuilder: ModelQueryBuilder<any>, relation: Relation, models: T[]): Promise<ModelWithoutRelations<T>[]>;
|
|
2753
2806
|
protected getRelatedModelsQueryForRelation(relationQueryBuilder: ModelQueryBuilder<any>, relation: Relation, models: T[]): ModelQueryBuilder<T>;
|
|
2754
2807
|
protected getFilterValuesFromModelsForRelation(relation: Relation, models: T[]): any[];
|
|
2755
|
-
protected applyHavingRelatedFilter(relationQueryBuilder: ModelQueryBuilder<any>, relation: Relation, operator?: BinaryOperatorType
|
|
2808
|
+
protected applyHavingRelatedFilter(relationQueryBuilder: ModelQueryBuilder<any>, relation: Relation, operator?: BinaryOperatorType, value?: BaseValues): void;
|
|
2756
2809
|
protected addAdditionalColumnsToModel(row: any, typeofModel: typeof Model): Record<string, any>;
|
|
2810
|
+
private manyWithPerformance;
|
|
2811
|
+
private oneWithPerformance;
|
|
2812
|
+
private oneOrFailWithPerformance;
|
|
2813
|
+
private firstOrFailWithPerformance;
|
|
2814
|
+
private firstWithPerformance;
|
|
2815
|
+
private paginateWithPerformance;
|
|
2816
|
+
private paginateWithCursorWithPerformance;
|
|
2817
|
+
private existsWithPerformance;
|
|
2818
|
+
private pluckWithPerformance;
|
|
2819
|
+
private softDeleteWithPerformance;
|
|
2820
|
+
private updateWithPerformance;
|
|
2821
|
+
private deleteWithPerformance;
|
|
2822
|
+
private truncateWithPerformance;
|
|
2757
2823
|
}
|
|
2758
2824
|
|
|
2759
2825
|
declare class ModelManager<T extends Model> {
|
|
@@ -2876,7 +2942,7 @@ declare class SqlDataSource extends DataSource {
|
|
|
2876
2942
|
/**
|
|
2877
2943
|
* @description Options provided in the sql data source initialization
|
|
2878
2944
|
*/
|
|
2879
|
-
inputDetails: SqlDataSourceInput
|
|
2945
|
+
inputDetails: SqlDataSourceInput<SqlDataSourceType>;
|
|
2880
2946
|
/**
|
|
2881
2947
|
* @description Establishes the default singleton connection used by default by all the Models, if not configuration is passed, env variables will be used instead
|
|
2882
2948
|
* @description You can continue to use the global sql class exported by hysteria after the connection without having to rely on the return of this function
|
|
@@ -2893,7 +2959,7 @@ declare class SqlDataSource extends DataSource {
|
|
|
2893
2959
|
* User.query(); // Will use the default connection
|
|
2894
2960
|
* ```
|
|
2895
2961
|
*/
|
|
2896
|
-
static connect<T extends Record<string, SqlDataSourceModel> = {}>(input: SqlDataSourceInput<T>, cb?: (sqlDataSource: AugmentedSqlDataSource<T>) => Promise<void> | void): Promise<AugmentedSqlDataSource<T>>;
|
|
2962
|
+
static connect<U extends SqlDataSourceType, T extends Record<string, SqlDataSourceModel> = {}>(input: SqlDataSourceInput<U, T>, cb?: (sqlDataSource: AugmentedSqlDataSource<T>) => Promise<void> | void): Promise<AugmentedSqlDataSource<T>>;
|
|
2897
2963
|
static connect<T extends Record<string, SqlDataSourceModel> = {}>(cb?: (sqlDataSource: AugmentedSqlDataSource<T>) => Promise<void> | void): Promise<SqlDataSource>;
|
|
2898
2964
|
/**
|
|
2899
2965
|
* @description Get's another database connection and return it, this won't be marked as the default connection used by the Models, for that use the static method `connect`
|
|
@@ -2908,7 +2974,7 @@ declare class SqlDataSource extends DataSource {
|
|
|
2908
2974
|
* const user = await User.query({ connection: anotherSql }).many();
|
|
2909
2975
|
* ```
|
|
2910
2976
|
*/
|
|
2911
|
-
static connectToSecondarySource<T extends Record<string, SqlDataSourceModel> = {}>(input: SqlDataSourceInput<T>, cb?: (sqlDataSource: AugmentedSqlDataSource<T>) => Promise<void> | void): Promise<AugmentedSqlDataSource<T>>;
|
|
2977
|
+
static connectToSecondarySource<U extends SqlDataSourceType, T extends Record<string, SqlDataSourceModel> = {}>(input: SqlDataSourceInput<U, T>, cb?: (sqlDataSource: AugmentedSqlDataSource<T>) => Promise<void> | void): Promise<AugmentedSqlDataSource<T>>;
|
|
2912
2978
|
static connectToSecondarySource<T extends Record<string, SqlDataSourceModel> = {}>(cb?: (sqlDataSource: AugmentedSqlDataSource<T>) => Promise<void> | void): Promise<SqlDataSource>;
|
|
2913
2979
|
/**
|
|
2914
2980
|
* @description Creates a new connection and executes a callback with the new instance, the connection is automatically closed after the callback is executed, so it's lifespan is only inside the callback
|
|
@@ -2923,7 +2989,7 @@ declare class SqlDataSource extends DataSource {
|
|
|
2923
2989
|
* });
|
|
2924
2990
|
* ```
|
|
2925
2991
|
*/
|
|
2926
|
-
static useConnection<T extends Record<string, SqlDataSourceModel> = {}>(connectionDetails: UseConnectionInput<T>, cb: (sqlDataSource: AugmentedSqlDataSource<T>) => Promise<void>): Promise<void>;
|
|
2992
|
+
static useConnection<U extends SqlDataSourceType, T extends Record<string, SqlDataSourceModel> = {}>(connectionDetails: UseConnectionInput<U, T>, cb: (sqlDataSource: AugmentedSqlDataSource<T>) => Promise<void>): Promise<void>;
|
|
2927
2993
|
/**
|
|
2928
2994
|
* @description Returns the instance of the SqlDataSource
|
|
2929
2995
|
* @throws {HysteriaError} If the connection is not established
|
|
@@ -2934,8 +3000,10 @@ declare class SqlDataSource extends DataSource {
|
|
|
2934
3000
|
* @description Query builder from the SqlDataSource instance returns raw data from the database, the data is not parsed or serialized in any way
|
|
2935
3001
|
* @description Optimal for performance-critical operations
|
|
2936
3002
|
* @description Use Models to have type safety and serialization
|
|
3003
|
+
* @description Default soft delete column is "deleted_at" with stringed date value
|
|
3004
|
+
* @param table The table name to query from, must be in valid sql format `table` or `table as alias`
|
|
2937
3005
|
*/
|
|
2938
|
-
static query(table:
|
|
3006
|
+
static query<S extends string>(table: TableFormat<S>, options?: RawModelOptions): QueryBuilder;
|
|
2939
3007
|
/**
|
|
2940
3008
|
* @description Creates a table on the database, return the query to be executed to create the table
|
|
2941
3009
|
*/
|
|
@@ -3026,8 +3094,10 @@ declare class SqlDataSource extends DataSource {
|
|
|
3026
3094
|
* @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
3095
|
* @description Optimal for performance-critical operations
|
|
3028
3096
|
* @description Use Models to have type safety and serialization
|
|
3097
|
+
* @description Default soft delete column is "deleted_at" with stringed date value
|
|
3098
|
+
* @param table The table name to query from, must be in valid sql format `table` or `table as alias`
|
|
3029
3099
|
*/
|
|
3030
|
-
query(table:
|
|
3100
|
+
query<S extends string>(table: TableFormat<S>, options?: RawModelOptions): QueryBuilder;
|
|
3031
3101
|
/**
|
|
3032
3102
|
* @description Return the query to alter the given table schema
|
|
3033
3103
|
*/
|
|
@@ -3101,7 +3171,7 @@ declare class SqlDataSource extends DataSource {
|
|
|
3101
3171
|
* @description If there is an active global transaction, it will be rolled back
|
|
3102
3172
|
*/
|
|
3103
3173
|
closeConnection(): Promise<void>;
|
|
3104
|
-
getConnectionDetails(): SqlDataSourceInput
|
|
3174
|
+
getConnectionDetails(): SqlDataSourceInput<SqlDataSourceType>;
|
|
3105
3175
|
/**
|
|
3106
3176
|
* @alias closeConnection
|
|
3107
3177
|
*/
|
|
@@ -3163,7 +3233,7 @@ declare class SqlDataSource extends DataSource {
|
|
|
3163
3233
|
get registeredModels(): Record<string, typeof Model>;
|
|
3164
3234
|
}
|
|
3165
3235
|
|
|
3166
|
-
type SqlDriverSpecificOptions = Omit<DriverSpecificOptions
|
|
3236
|
+
type SqlDriverSpecificOptions<T extends DataSourceType> = Omit<DriverSpecificOptions<T>, "mongoOptions" | "redisOptions">;
|
|
3167
3237
|
type MysqlConnectionInstance = Awaited<ReturnType<Mysql2Import["createPool"]>>;
|
|
3168
3238
|
type PgPoolClientInstance = InstanceType<PgImport["Pool"]>;
|
|
3169
3239
|
type SqliteConnectionInstance = InstanceType<Sqlite3Import["Database"]>;
|
|
@@ -3173,6 +3243,9 @@ type SqlPoolType = MysqlConnectionInstance | PgPoolClientInstance | SqliteConnec
|
|
|
3173
3243
|
* @default By default, the connection policies are not set, so no query will be retried
|
|
3174
3244
|
*/
|
|
3175
3245
|
type ConnectionPolicies = {
|
|
3246
|
+
/**
|
|
3247
|
+
* @description The retry policy for the sql data source, it allows to retry a query if it fails
|
|
3248
|
+
*/
|
|
3176
3249
|
retry?: {
|
|
3177
3250
|
maxRetries?: number;
|
|
3178
3251
|
delay?: number;
|
|
@@ -3183,7 +3256,7 @@ type SqlDataSourceModel = typeof Model;
|
|
|
3183
3256
|
* @description The input type for the SqlDataSource constructor
|
|
3184
3257
|
* @description The connectionPolicies object is used to configure the connection policies for the sql data source
|
|
3185
3258
|
*/
|
|
3186
|
-
type SqlDataSourceInput<T extends Record<string, SqlDataSourceModel> = {}> = {
|
|
3259
|
+
type SqlDataSourceInput<D extends SqlDataSourceType, T extends Record<string, SqlDataSourceModel> = {}> = {
|
|
3187
3260
|
readonly type?: Exclude<DataSourceType, "mongo">;
|
|
3188
3261
|
/**
|
|
3189
3262
|
* @description Whether to log the sql queries and other debug information
|
|
@@ -3205,13 +3278,13 @@ type SqlDataSourceInput<T extends Record<string, SqlDataSourceModel> = {}> = {
|
|
|
3205
3278
|
/**
|
|
3206
3279
|
* @description The driver specific options to use for the sql data source, it's used to configure the driver specific options for the sql data source
|
|
3207
3280
|
*/
|
|
3208
|
-
driverOptions?: SqlDriverSpecificOptions
|
|
3281
|
+
driverOptions?: SqlDriverSpecificOptions<D>;
|
|
3209
3282
|
} & (MysqlSqlDataSourceInput | PostgresSqlDataSourceInput | SqliteDataSourceInput);
|
|
3210
|
-
type UseConnectionInput<T extends Record<string, SqlDataSourceModel> = {}> = {
|
|
3283
|
+
type UseConnectionInput<D extends SqlDataSourceType, T extends Record<string, SqlDataSourceModel> = {}> = {
|
|
3211
3284
|
readonly type: Exclude<DataSourceType, "mongo">;
|
|
3212
3285
|
readonly logs?: boolean;
|
|
3213
3286
|
readonly models?: T;
|
|
3214
|
-
readonly driverOptions?: SqlDriverSpecificOptions
|
|
3287
|
+
readonly driverOptions?: SqlDriverSpecificOptions<D>;
|
|
3215
3288
|
connectionPolicies?: ConnectionPolicies;
|
|
3216
3289
|
queryFormatOptions?: FormatOptionsWithLanguage;
|
|
3217
3290
|
} & (NotNullableMysqlSqlDataSourceInput | NotNullablePostgresSqlDataSourceInput | NotNullableSqliteDataSourceInput);
|
|
@@ -3231,6 +3304,9 @@ type AugmentedSqlDataSource<T extends Record<string, SqlDataSourceModel> = {}> =
|
|
|
3231
3304
|
type SqlDataSourceWithoutTransaction<T extends Record<string, SqlDataSourceModel> = {}> = Pick<SqlDataSource, "sqlPool" | "sqlConnection" | "inputDetails" | "isConnected" | "getDbType" | "clone" | "getModelManager" | "getPool" | "getConnection" | "closeConnection" | "getConnectionDetails" | "disconnect" | "syncSchema" | "rawQuery" | "rawStatement" | "getTableSchema" | "getModelOpenApiSchema" | "getTableInfo" | "getIndexInfo" | "getForeignKeyInfo" | "getPrimaryKeyInfo" | "registeredModels" | "type" | "host" | "port" | "username" | "password" | "database" | "logs" | "query"> & {
|
|
3232
3305
|
[key in keyof T]: T[key];
|
|
3233
3306
|
};
|
|
3307
|
+
/** Only accepts formats `string` e `string as string` */
|
|
3308
|
+
type NoSpace<S extends string> = S extends `${infer _} ${infer _}` ? never : S;
|
|
3309
|
+
type TableFormat<S extends string> = NoSpace<S> | (S extends `${infer L} as ${infer R}` ? `${NoSpace<L>} as ${NoSpace<R>}` : never);
|
|
3234
3310
|
|
|
3235
3311
|
type AstParserType = {
|
|
3236
3312
|
sql: string;
|
|
@@ -3293,21 +3369,40 @@ declare class QueryBuilder<T extends Model = any> extends JsonQueryBuilder<T> {
|
|
|
3293
3369
|
data: boolean;
|
|
3294
3370
|
time: number;
|
|
3295
3371
|
}>;
|
|
3372
|
+
truncate: (returnType?: "millis" | "seconds") => Promise<{
|
|
3373
|
+
data: void;
|
|
3374
|
+
time: number;
|
|
3375
|
+
}>;
|
|
3376
|
+
delete: (returnType?: "millis" | "seconds") => Promise<{
|
|
3377
|
+
data: number;
|
|
3378
|
+
time: number;
|
|
3379
|
+
}>;
|
|
3380
|
+
insert: (data: Record<string, any>, returnType?: "millis" | "seconds") => Promise<{
|
|
3381
|
+
data: T;
|
|
3382
|
+
time: number;
|
|
3383
|
+
}>;
|
|
3384
|
+
insertMany: (data: Record<string, any>[], returnType?: "millis" | "seconds") => Promise<{
|
|
3385
|
+
data: T[];
|
|
3386
|
+
time: number;
|
|
3387
|
+
}>;
|
|
3388
|
+
update: (data: Record<string, any>, returnType?: "millis" | "seconds") => Promise<{
|
|
3389
|
+
data: number;
|
|
3390
|
+
time: number;
|
|
3391
|
+
}>;
|
|
3392
|
+
softDelete: (options?: Omit<SoftDeleteOptions<T>, "ignoreBeforeDeleteHook">, returnType?: "millis" | "seconds") => Promise<{
|
|
3393
|
+
data: number;
|
|
3394
|
+
time: number;
|
|
3395
|
+
}>;
|
|
3396
|
+
pluck: (key: ModelKey<T>, returnType?: "millis" | "seconds") => Promise<{
|
|
3397
|
+
data: PluckReturnType<T, ModelKey<T>>;
|
|
3398
|
+
time: number;
|
|
3399
|
+
}>;
|
|
3296
3400
|
};
|
|
3297
3401
|
constructor(model: typeof Model, sqlDataSource?: SqlDataSource);
|
|
3298
|
-
protected get fromTable(): string;
|
|
3299
3402
|
/**
|
|
3300
3403
|
* @description Executes the query and returns true if the query returns at least one result, false otherwise.
|
|
3301
3404
|
*/
|
|
3302
3405
|
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
3406
|
/**
|
|
3312
3407
|
* @description Executes the query and retrieves multiple results.
|
|
3313
3408
|
*/
|
|
@@ -3418,19 +3513,21 @@ declare class QueryBuilder<T extends Model = any> extends JsonQueryBuilder<T> {
|
|
|
3418
3513
|
unionAll(cb: UnionCallBack<T>): this;
|
|
3419
3514
|
unionAll(queryBuilder: QueryBuilder<any>): this;
|
|
3420
3515
|
/**
|
|
3421
|
-
* @description Increments the value of a column by a given amount
|
|
3516
|
+
* @description Increments the value of a column by a given amount
|
|
3422
3517
|
* @typeSafe - In typescript, only numeric columns of the model will be accepted if using a Model
|
|
3423
3518
|
* @default value + 1
|
|
3424
3519
|
* @returns the number of affected rows
|
|
3425
3520
|
*/
|
|
3426
|
-
increment(column:
|
|
3521
|
+
increment(column: string, value: number): Promise<number>;
|
|
3522
|
+
increment(column: NumberModelKey<T>, value: number): Promise<number>;
|
|
3427
3523
|
/**
|
|
3428
|
-
* @description Decrements the value of a column by a given amount
|
|
3524
|
+
* @description Decrements the value of a column by a given amount
|
|
3429
3525
|
* @typeSafe - In typescript, only numeric columns of the model will be accepted if using a Model
|
|
3430
3526
|
* @default value - 1
|
|
3431
3527
|
* @returns the number of affected rows
|
|
3432
3528
|
*/
|
|
3433
|
-
decrement(column:
|
|
3529
|
+
decrement(column: string, value: number): Promise<number>;
|
|
3530
|
+
decrement(column: NumberModelKey<T>, value: number): Promise<number>;
|
|
3434
3531
|
/**
|
|
3435
3532
|
* @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
3533
|
*/
|
|
@@ -3459,7 +3556,7 @@ declare class QueryBuilder<T extends Model = any> extends JsonQueryBuilder<T> {
|
|
|
3459
3556
|
/**
|
|
3460
3557
|
* @description Overrides the from clause in the query.
|
|
3461
3558
|
*/
|
|
3462
|
-
from(table:
|
|
3559
|
+
from<S extends string>(table: TableFormat<S>, alias?: string): this;
|
|
3463
3560
|
from(cb: (qb: QueryBuilder<T>) => void, alias: string): this;
|
|
3464
3561
|
/**
|
|
3465
3562
|
* @description Adds a CTE to the query using a callback to build the subquery.
|
|
@@ -3494,6 +3591,7 @@ declare class QueryBuilder<T extends Model = any> extends JsonQueryBuilder<T> {
|
|
|
3494
3591
|
update(data: Record<string, any>): Promise<number>;
|
|
3495
3592
|
/**
|
|
3496
3593
|
* @description Deletes all records from a table
|
|
3594
|
+
* @warning This operation does not trigger any hook
|
|
3497
3595
|
*/
|
|
3498
3596
|
truncate(): Promise<void>;
|
|
3499
3597
|
/**
|
|
@@ -3507,7 +3605,7 @@ declare class QueryBuilder<T extends Model = any> extends JsonQueryBuilder<T> {
|
|
|
3507
3605
|
* @default value - The current date and time in UTC timezone in the format "YYYY-MM-DD HH:mm:ss"
|
|
3508
3606
|
* @returns the number of affected rows
|
|
3509
3607
|
*/
|
|
3510
|
-
softDelete(options?: SoftDeleteOptions<T>): Promise<number>;
|
|
3608
|
+
softDelete(options?: Omit<SoftDeleteOptions<T>, "ignoreBeforeDeleteHook">): Promise<number>;
|
|
3511
3609
|
/**
|
|
3512
3610
|
* @description Returns the query with the parameters bound to the query
|
|
3513
3611
|
*/
|
|
@@ -3520,9 +3618,22 @@ declare class QueryBuilder<T extends Model = any> extends JsonQueryBuilder<T> {
|
|
|
3520
3618
|
* @description Returns a deep clone of the query builder instance.
|
|
3521
3619
|
*/
|
|
3522
3620
|
clone(): this;
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3621
|
+
/**
|
|
3622
|
+
* @description Gives a fresh instance of the query builder
|
|
3623
|
+
*/
|
|
3624
|
+
clear(): QueryBuilder<any>;
|
|
3625
|
+
/**
|
|
3626
|
+
* @description Removes the lock query
|
|
3627
|
+
*/
|
|
3628
|
+
clearLockQuery(): this;
|
|
3629
|
+
/**
|
|
3630
|
+
* @description Removes any union query
|
|
3631
|
+
*/
|
|
3632
|
+
clearUnionQuery(): this;
|
|
3633
|
+
/**
|
|
3634
|
+
* @description Removes any with query
|
|
3635
|
+
*/
|
|
3636
|
+
clearWithQuery(): this;
|
|
3526
3637
|
extractQueryNodes(): QueryNode[];
|
|
3527
3638
|
protected clearForFunctions(): this;
|
|
3528
3639
|
/**
|
|
@@ -3547,18 +3658,30 @@ declare class QueryBuilder<T extends Model = any> extends JsonQueryBuilder<T> {
|
|
|
3547
3658
|
* @description Makes a one or fail query and returns the time that took to execute that query
|
|
3548
3659
|
*/
|
|
3549
3660
|
private oneOrFailWithPerformance;
|
|
3661
|
+
/**
|
|
3662
|
+
* @description Executes the query and returns true if the query returns at least one result, false otherwise.
|
|
3663
|
+
* @description Returns the time that took to execute the query
|
|
3664
|
+
*/
|
|
3665
|
+
private existsWithPerformance;
|
|
3666
|
+
private pluckWithPerformance;
|
|
3667
|
+
private updateWithPerformance;
|
|
3668
|
+
private insertWithPerformance;
|
|
3669
|
+
private insertManyWithPerformance;
|
|
3670
|
+
private softDeleteWithPerformance;
|
|
3671
|
+
private deleteWithPerformance;
|
|
3672
|
+
private truncateWithPerformance;
|
|
3550
3673
|
}
|
|
3551
3674
|
|
|
3552
3675
|
type UnionCallBack<T extends Model> = (queryBuilder: QueryBuilder<T>) => QueryBuilder<T>;
|
|
3553
3676
|
type SqlMethod = "sum" | "avg" | "max" | "min" | "count" | "upper" | "lower" | "trim" | "length" | "cast" | "convert" | "abs" | "round" | "floor" | "ceil";
|
|
3554
3677
|
|
|
3555
3678
|
type ModelInstanceType<O> = O extends typeof Model ? InstanceType<O> : never;
|
|
3556
|
-
type FetchHooks = "beforeFetch" | "afterFetch";
|
|
3679
|
+
type FetchHooks = ["afterFetch"] | ["beforeFetch"] | ["afterFetch", "beforeFetch"] | ["beforeFetch", "afterFetch"] | [];
|
|
3557
3680
|
type OneOptions = {
|
|
3558
|
-
ignoreHooks?: FetchHooks
|
|
3681
|
+
ignoreHooks?: FetchHooks;
|
|
3559
3682
|
};
|
|
3560
3683
|
type ManyOptions = {
|
|
3561
|
-
ignoreHooks?: FetchHooks
|
|
3684
|
+
ignoreHooks?: FetchHooks;
|
|
3562
3685
|
};
|
|
3563
3686
|
type AnnotatedModel<T extends Model, A extends object = {}, R extends object = {}> = [keyof A] extends [never] ? ModelWithoutRelations<T> & R : ModelWithoutRelations<T> & {
|
|
3564
3687
|
$annotations: A;
|
|
@@ -3648,7 +3771,7 @@ type OrderByType<T extends Model> = {
|
|
|
3648
3771
|
type UnrestrictedFindOneType<T extends Model, S extends ModelKey<T>[] = any[], R extends ModelRelation<T>[] = never[]> = {
|
|
3649
3772
|
select?: S;
|
|
3650
3773
|
relations?: R;
|
|
3651
|
-
ignoreHooks?: FetchHooks
|
|
3774
|
+
ignoreHooks?: FetchHooks;
|
|
3652
3775
|
where?: Record<string, any>;
|
|
3653
3776
|
orderBy?: OrderByType<T>;
|
|
3654
3777
|
groupBy?: string[];
|
|
@@ -3664,7 +3787,7 @@ type FindOneType<T extends Model, S extends ModelKey<T>[] = any[], R extends Mod
|
|
|
3664
3787
|
orderBy?: OrderByType<T>;
|
|
3665
3788
|
groupBy?: ModelKey<T>[];
|
|
3666
3789
|
where?: WhereType<T>;
|
|
3667
|
-
ignoreHooks?: FetchHooks
|
|
3790
|
+
ignoreHooks?: FetchHooks;
|
|
3668
3791
|
};
|
|
3669
3792
|
type FindType<T extends Model, S extends ModelKey<T>[] = any[], R extends ModelRelation<T>[] = never[]> = Omit<FindOneType<T, S, R>, "throwErrorOnNull"> & {
|
|
3670
3793
|
limit?: number;
|
|
@@ -3692,7 +3815,7 @@ declare abstract class Model extends Entity {
|
|
|
3692
3815
|
* @description The value used to soft delete a record, default is the current date and time
|
|
3693
3816
|
* @default format: "YYYY-MM-DD HH:mm:ss" in UTC timezone
|
|
3694
3817
|
*/
|
|
3695
|
-
static softDeleteValue: string;
|
|
3818
|
+
static softDeleteValue: boolean | string;
|
|
3696
3819
|
/**
|
|
3697
3820
|
* @description The sql sqlInstance generated by SqlDataSource.connect
|
|
3698
3821
|
*/
|
|
@@ -3851,12 +3974,12 @@ declare abstract class Model extends Entity {
|
|
|
3851
3974
|
*/
|
|
3852
3975
|
static combineProps<T extends Model>(sqlInstance: Partial<T>, data: Partial<T>): void;
|
|
3853
3976
|
/**
|
|
3854
|
-
* @description Adds a beforeFetch clause to the model, adding the ability to modify the
|
|
3977
|
+
* @description Adds a beforeFetch clause to the model, adding the ability to modify the querybuilder before fetching the data
|
|
3855
3978
|
*/
|
|
3856
|
-
static beforeFetch?(queryBuilder: ModelQueryBuilder<any>): void;
|
|
3979
|
+
static beforeFetch?(queryBuilder: ModelQueryBuilder<any>): Promise<void> | void;
|
|
3857
3980
|
/**
|
|
3858
|
-
* @description Adds a beforeInsert clause to the model
|
|
3859
|
-
* @param {Model} data The
|
|
3981
|
+
* @description Adds a beforeInsert clause to the model modifying the data before inserting the data
|
|
3982
|
+
* @param {Model} data The model to be inserted, in insertMany the hook will be called for each model
|
|
3860
3983
|
* @example
|
|
3861
3984
|
* ```typescript
|
|
3862
3985
|
* static async beforeInsert?(data: User): Promise<void> {
|
|
@@ -3865,25 +3988,40 @@ declare abstract class Model extends Entity {
|
|
|
3865
3988
|
* ```
|
|
3866
3989
|
*/
|
|
3867
3990
|
static beforeInsert?(data: any): Promise<void> | void;
|
|
3991
|
+
/**
|
|
3992
|
+
* @description Adds a beforeInsertMany clause to the model modifying the data before inserting the data
|
|
3993
|
+
* @param {Model[]} data The models to be inserted, in insertMany the hook will be called for each model
|
|
3994
|
+
* @example
|
|
3995
|
+
* ```typescript
|
|
3996
|
+
* static async beforeInsertMany?(data: User[]): Promise<void> {
|
|
3997
|
+
* data.forEach((user) => {
|
|
3998
|
+
* user.name = user.name.toUpperCase();
|
|
3999
|
+
* });
|
|
4000
|
+
* }
|
|
4001
|
+
* ```
|
|
4002
|
+
*/
|
|
4003
|
+
static beforeInsertMany?(data: any[]): Promise<void> | void;
|
|
3868
4004
|
/**
|
|
3869
4005
|
* @description Adds a beforeUpdate clause to the model, adding the ability to modify the query before updating the data
|
|
4006
|
+
* @description Includes soft delete
|
|
3870
4007
|
*/
|
|
3871
|
-
static beforeUpdate?(queryBuilder: ModelQueryBuilder<any>): void;
|
|
4008
|
+
static beforeUpdate?(queryBuilder: ModelQueryBuilder<any>): Promise<void> | void;
|
|
3872
4009
|
/**
|
|
3873
4010
|
* @description Adds a beforeDelete clause to the model, adding the ability to modify the query before deleting the data
|
|
4011
|
+
* @warning This hook does not include soft delete since it's an update operation
|
|
3874
4012
|
*/
|
|
3875
|
-
static beforeDelete?(queryBuilder: ModelQueryBuilder<any>): void;
|
|
4013
|
+
static beforeDelete?(queryBuilder: ModelQueryBuilder<any>): Promise<void> | void;
|
|
3876
4014
|
/**
|
|
3877
4015
|
* @description Adds a afterFetch clause to the model, adding the ability to modify the data after fetching the data
|
|
3878
|
-
* @param {Model} data
|
|
4016
|
+
* @param {Model} data Models fetched from the database, must always provide an implementation for an array of models regardless of the query result
|
|
3879
4017
|
* @example
|
|
3880
4018
|
* ```typescript
|
|
3881
|
-
* static async afterFetch?(data: User): Promise<User> {
|
|
4019
|
+
* static async afterFetch?(data: User[]): Promise<User[]> {
|
|
3882
4020
|
* return data;
|
|
3883
4021
|
* }
|
|
3884
4022
|
* ```
|
|
3885
4023
|
*/
|
|
3886
|
-
static afterFetch?(data: any): Promise<any> | any;
|
|
4024
|
+
static afterFetch?(data: any[]): Promise<any[]> | any[];
|
|
3887
4025
|
/**
|
|
3888
4026
|
* @description Returns the columns of the model
|
|
3889
4027
|
*/
|
|
@@ -4164,10 +4302,16 @@ type RedisStorable = string | number | boolean | Buffer | Array<any> | Record<st
|
|
|
4164
4302
|
* @description The RedisFetchable type is a type that can be fetched from redis
|
|
4165
4303
|
*/
|
|
4166
4304
|
type RedisFetchable = string | number | boolean | Record<string, any> | Array<any> | null;
|
|
4305
|
+
/**
|
|
4306
|
+
* @description Type for Redis message handler callback
|
|
4307
|
+
*/
|
|
4308
|
+
type RedisMessageHandler = (channel: string, message: string) => void;
|
|
4167
4309
|
/**
|
|
4168
4310
|
* @description The RedisDataSource class is a wrapper around the ioredis library that provides a simple interface to interact with a redis database
|
|
4169
4311
|
*/
|
|
4170
4312
|
declare class RedisDataSource {
|
|
4313
|
+
static readonly OK = "OK";
|
|
4314
|
+
readonly OK = "OK";
|
|
4171
4315
|
static isConnected: boolean;
|
|
4172
4316
|
protected static redisDataSourceInstance: RedisDataSource;
|
|
4173
4317
|
isConnected: boolean;
|
|
@@ -4276,6 +4420,610 @@ declare class RedisDataSource {
|
|
|
4276
4420
|
* @returns {Promise<void>}
|
|
4277
4421
|
*/
|
|
4278
4422
|
disconnect(forceError?: boolean): Promise<void>;
|
|
4423
|
+
/**
|
|
4424
|
+
* @description Adds one or more values to the beginning of a list
|
|
4425
|
+
* @param {string} key - The key of the list
|
|
4426
|
+
* @param {RedisStorable[]} values - The values to add
|
|
4427
|
+
* @returns {Promise<number>} - The length of the list after the push operation
|
|
4428
|
+
*/
|
|
4429
|
+
static lpush(key: string, ...values: RedisStorable[]): Promise<number>;
|
|
4430
|
+
/**
|
|
4431
|
+
* @description Adds one or more values to the end of a list
|
|
4432
|
+
* @param {string} key - The key of the list
|
|
4433
|
+
* @param {RedisStorable[]} values - The values to add
|
|
4434
|
+
* @returns {Promise<number>} - The length of the list after the push operation
|
|
4435
|
+
*/
|
|
4436
|
+
static rpush(key: string, ...values: RedisStorable[]): Promise<number>;
|
|
4437
|
+
/**
|
|
4438
|
+
* @description Removes and returns the first element of a list
|
|
4439
|
+
* @param {string} key - The key of the list
|
|
4440
|
+
* @returns {Promise<T | null>} - The popped value
|
|
4441
|
+
*/
|
|
4442
|
+
static lpop<T = RedisFetchable>(key: string): Promise<T | null>;
|
|
4443
|
+
/**
|
|
4444
|
+
* @description Removes and returns the last element of a list
|
|
4445
|
+
* @param {string} key - The key of the list
|
|
4446
|
+
* @returns {Promise<T | null>} - The popped value
|
|
4447
|
+
*/
|
|
4448
|
+
static rpop<T = RedisFetchable>(key: string): Promise<T | null>;
|
|
4449
|
+
/**
|
|
4450
|
+
* @description Gets a range of elements from a list
|
|
4451
|
+
* @param {string} key - The key of the list
|
|
4452
|
+
* @param {number} start - The starting index
|
|
4453
|
+
* @param {number} stop - The stopping index
|
|
4454
|
+
* @returns {Promise<T[]>} - Array of elements in the specified range
|
|
4455
|
+
*/
|
|
4456
|
+
static lrange<T = RedisFetchable>(key: string, start: number, stop: number): Promise<T[]>;
|
|
4457
|
+
/**
|
|
4458
|
+
* @description Gets the length of a list
|
|
4459
|
+
* @param {string} key - The key of the list
|
|
4460
|
+
* @returns {Promise<number>} - The length of the list
|
|
4461
|
+
*/
|
|
4462
|
+
static llen(key: string): Promise<number>;
|
|
4463
|
+
/**
|
|
4464
|
+
* @description Adds one or more values to the beginning of a list
|
|
4465
|
+
* @param {string} key - The key of the list
|
|
4466
|
+
* @param {RedisStorable[]} values - The values to add
|
|
4467
|
+
* @returns {Promise<number>} - The length of the list after the push operation
|
|
4468
|
+
*/
|
|
4469
|
+
lpush(key: string, ...values: RedisStorable[]): Promise<number>;
|
|
4470
|
+
/**
|
|
4471
|
+
* @description Adds one or more values to the end of a list
|
|
4472
|
+
* @param {string} key - The key of the list
|
|
4473
|
+
* @param {RedisStorable[]} values - The values to add
|
|
4474
|
+
* @returns {Promise<number>} - The length of the list after the push operation
|
|
4475
|
+
*/
|
|
4476
|
+
rpush(key: string, ...values: RedisStorable[]): Promise<number>;
|
|
4477
|
+
/**
|
|
4478
|
+
* @description Removes and returns the first element of a list
|
|
4479
|
+
* @param {string} key - The key of the list
|
|
4480
|
+
* @returns {Promise<T | null>} - The popped value
|
|
4481
|
+
*/
|
|
4482
|
+
lpop<T = RedisFetchable>(key: string): Promise<T | null>;
|
|
4483
|
+
/**
|
|
4484
|
+
* @description Removes and returns the last element of a list
|
|
4485
|
+
* @param {string} key - The key of the list
|
|
4486
|
+
* @returns {Promise<T | null>} - The popped value
|
|
4487
|
+
*/
|
|
4488
|
+
rpop<T = RedisFetchable>(key: string): Promise<T | null>;
|
|
4489
|
+
/**
|
|
4490
|
+
* @description Gets a range of elements from a list
|
|
4491
|
+
* @param {string} key - The key of the list
|
|
4492
|
+
* @param {number} start - The starting index
|
|
4493
|
+
* @param {number} stop - The stopping index
|
|
4494
|
+
* @returns {Promise<T[]>} - Array of elements in the specified range
|
|
4495
|
+
*/
|
|
4496
|
+
lrange<T = RedisFetchable>(key: string, start: number, stop: number): Promise<T[]>;
|
|
4497
|
+
/**
|
|
4498
|
+
* @description Gets the length of a list
|
|
4499
|
+
* @param {string} key - The key of the list
|
|
4500
|
+
* @returns {Promise<number>} - The length of the list
|
|
4501
|
+
*/
|
|
4502
|
+
llen(key: string): Promise<number>;
|
|
4503
|
+
/**
|
|
4504
|
+
* @description Sets field in the hash stored at key to value
|
|
4505
|
+
* @param {string} key - The key of the hash
|
|
4506
|
+
* @param {string} field - The field to set
|
|
4507
|
+
* @param {RedisStorable} value - The value to set
|
|
4508
|
+
* @returns {Promise<number>} - 1 if field is a new field and value was set, 0 if field already exists and the value was updated
|
|
4509
|
+
*/
|
|
4510
|
+
static hset(key: string, field: string, value: RedisStorable): Promise<number>;
|
|
4511
|
+
/**
|
|
4512
|
+
* @description Sets multiple fields in the hash stored at key to their respective values
|
|
4513
|
+
* @param {string} key - The key of the hash
|
|
4514
|
+
* @param {Record<string, RedisStorable>} hash - Object containing field-value pairs
|
|
4515
|
+
* @returns {Promise<string>} - "OK" if successful
|
|
4516
|
+
*/
|
|
4517
|
+
static hmset(key: string, hash: Record<string, RedisStorable>): Promise<string>;
|
|
4518
|
+
/**
|
|
4519
|
+
* @description Gets the value of a field in a hash
|
|
4520
|
+
* @param {string} key - The key of the hash
|
|
4521
|
+
* @param {string} field - The field to get
|
|
4522
|
+
* @returns {Promise<T | null>} - The value of the field
|
|
4523
|
+
*/
|
|
4524
|
+
static hget<T = RedisFetchable>(key: string, field: string): Promise<T | null>;
|
|
4525
|
+
/**
|
|
4526
|
+
* @description Gets all the fields and values in a hash
|
|
4527
|
+
* @param {string} key - The key of the hash
|
|
4528
|
+
* @returns {Promise<Record<string, T>>} - Object containing field-value pairs
|
|
4529
|
+
*/
|
|
4530
|
+
static hgetall<T = RedisFetchable>(key: string): Promise<Record<string, T>>;
|
|
4531
|
+
/**
|
|
4532
|
+
* @description Gets values for multiple fields in a hash
|
|
4533
|
+
* @param {string} key - The key of the hash
|
|
4534
|
+
* @param {string[]} fields - The fields to get
|
|
4535
|
+
* @returns {Promise<Array<T | null>>} - Array of values
|
|
4536
|
+
*/
|
|
4537
|
+
static hmget<T = RedisFetchable>(key: string, ...fields: string[]): Promise<Array<T | null>>;
|
|
4538
|
+
/**
|
|
4539
|
+
* @description Deletes one or more fields from a hash
|
|
4540
|
+
* @param {string} key - The key of the hash
|
|
4541
|
+
* @param {string[]} fields - The fields to delete
|
|
4542
|
+
* @returns {Promise<number>} - The number of fields that were removed
|
|
4543
|
+
*/
|
|
4544
|
+
static hdel(key: string, ...fields: string[]): Promise<number>;
|
|
4545
|
+
/**
|
|
4546
|
+
* @description Checks if a field exists in a hash
|
|
4547
|
+
* @param {string} key - The key of the hash
|
|
4548
|
+
* @param {string} field - The field to check
|
|
4549
|
+
* @returns {Promise<number>} - 1 if the field exists, 0 if not
|
|
4550
|
+
*/
|
|
4551
|
+
static hexists(key: string, field: string): Promise<number>;
|
|
4552
|
+
/**
|
|
4553
|
+
* @description Gets all the fields in a hash
|
|
4554
|
+
* @param {string} key - The key of the hash
|
|
4555
|
+
* @returns {Promise<string[]>} - Array of field names
|
|
4556
|
+
*/
|
|
4557
|
+
static hkeys(key: string): Promise<string[]>;
|
|
4558
|
+
/**
|
|
4559
|
+
* @description Gets the number of fields in a hash
|
|
4560
|
+
* @param {string} key - The key of the hash
|
|
4561
|
+
* @returns {Promise<number>} - The number of fields
|
|
4562
|
+
*/
|
|
4563
|
+
static hlen(key: string): Promise<number>;
|
|
4564
|
+
/**
|
|
4565
|
+
* @description Sets field in the hash stored at key to value
|
|
4566
|
+
* @param {string} key - The key of the hash
|
|
4567
|
+
* @param {string} field - The field to set
|
|
4568
|
+
* @param {RedisStorable} value - The value to set
|
|
4569
|
+
* @returns {Promise<number>} - 1 if field is a new field and value was set, 0 if field already exists and the value was updated
|
|
4570
|
+
*/
|
|
4571
|
+
hset(key: string, field: string, value: RedisStorable): Promise<number>;
|
|
4572
|
+
/**
|
|
4573
|
+
* @description Sets multiple fields in the hash stored at key to their respective values
|
|
4574
|
+
* @param {string} key - The key of the hash
|
|
4575
|
+
* @param {Record<string, RedisStorable>} hash - Object containing field-value pairs
|
|
4576
|
+
* @returns {Promise<string>} - "OK" if successful
|
|
4577
|
+
*/
|
|
4578
|
+
hmset(key: string, hash: Record<string, RedisStorable>): Promise<string>;
|
|
4579
|
+
/**
|
|
4580
|
+
* @description Gets the value of a field in a hash
|
|
4581
|
+
* @param {string} key - The key of the hash
|
|
4582
|
+
* @param {string} field - The field to get
|
|
4583
|
+
* @returns {Promise<T | null>} - The value of the field
|
|
4584
|
+
*/
|
|
4585
|
+
hget<T = RedisFetchable>(key: string, field: string): Promise<T | null>;
|
|
4586
|
+
/**
|
|
4587
|
+
* @description Gets all the fields and values in a hash
|
|
4588
|
+
* @param {string} key - The key of the hash
|
|
4589
|
+
* @returns {Promise<Record<string, T>>} - Object containing field-value pairs
|
|
4590
|
+
*/
|
|
4591
|
+
hgetall<T = RedisFetchable>(key: string): Promise<Record<string, T>>;
|
|
4592
|
+
/**
|
|
4593
|
+
* @description Gets values for multiple fields in a hash
|
|
4594
|
+
* @param {string} key - The key of the hash
|
|
4595
|
+
* @param {string[]} fields - The fields to get
|
|
4596
|
+
* @returns {Promise<Array<T | null>>} - Array of values
|
|
4597
|
+
*/
|
|
4598
|
+
hmget<T = RedisFetchable>(key: string, ...fields: string[]): Promise<Array<T | null>>;
|
|
4599
|
+
/**
|
|
4600
|
+
* @description Deletes one or more fields from a hash
|
|
4601
|
+
* @param {string} key - The key of the hash
|
|
4602
|
+
* @param {string[]} fields - The fields to delete
|
|
4603
|
+
* @returns {Promise<number>} - The number of fields that were removed
|
|
4604
|
+
*/
|
|
4605
|
+
hdel(key: string, ...fields: string[]): Promise<number>;
|
|
4606
|
+
/**
|
|
4607
|
+
* @description Checks if a field exists in a hash
|
|
4608
|
+
* @param {string} key - The key of the hash
|
|
4609
|
+
* @param {string} field - The field to check
|
|
4610
|
+
* @returns {Promise<number>} - 1 if the field exists, 0 if not
|
|
4611
|
+
*/
|
|
4612
|
+
hexists(key: string, field: string): Promise<number>;
|
|
4613
|
+
/**
|
|
4614
|
+
* @description Gets all the fields in a hash
|
|
4615
|
+
* @param {string} key - The key of the hash
|
|
4616
|
+
* @returns {Promise<string[]>} - Array of field names
|
|
4617
|
+
*/
|
|
4618
|
+
hkeys(key: string): Promise<string[]>;
|
|
4619
|
+
/**
|
|
4620
|
+
* @description Gets the number of fields in a hash
|
|
4621
|
+
* @param {string} key - The key of the hash
|
|
4622
|
+
* @returns {Promise<number>} - The number of fields
|
|
4623
|
+
*/
|
|
4624
|
+
hlen(key: string): Promise<number>;
|
|
4625
|
+
/**
|
|
4626
|
+
* @description Adds one or more members to a set
|
|
4627
|
+
* @param {string} key - The key of the set
|
|
4628
|
+
* @param {RedisStorable[]} members - The members to add
|
|
4629
|
+
* @returns {Promise<number>} - The number of elements added to the set
|
|
4630
|
+
*/
|
|
4631
|
+
static sadd(key: string, ...members: RedisStorable[]): Promise<number>;
|
|
4632
|
+
/**
|
|
4633
|
+
* @description Gets all members of a set
|
|
4634
|
+
* @param {string} key - The key of the set
|
|
4635
|
+
* @returns {Promise<T[]>} - Array of set members
|
|
4636
|
+
*/
|
|
4637
|
+
static smembers<T = RedisFetchable>(key: string): Promise<T[]>;
|
|
4638
|
+
/**
|
|
4639
|
+
* @description Removes one or more members from a set
|
|
4640
|
+
* @param {string} key - The key of the set
|
|
4641
|
+
* @param {RedisStorable[]} members - The members to remove
|
|
4642
|
+
* @returns {Promise<number>} - The number of members that were removed
|
|
4643
|
+
*/
|
|
4644
|
+
static srem(key: string, ...members: RedisStorable[]): Promise<number>;
|
|
4645
|
+
/**
|
|
4646
|
+
* @description Determines whether a member belongs to a set
|
|
4647
|
+
* @param {string} key - The key of the set
|
|
4648
|
+
* @param {RedisStorable} member - The member to check
|
|
4649
|
+
* @returns {Promise<number>} - 1 if the member exists in the set, 0 if not
|
|
4650
|
+
*/
|
|
4651
|
+
static sismember(key: string, member: RedisStorable): Promise<number>;
|
|
4652
|
+
/**
|
|
4653
|
+
* @description Gets the number of members in a set
|
|
4654
|
+
* @param {string} key - The key of the set
|
|
4655
|
+
* @returns {Promise<number>} - The number of members in the set
|
|
4656
|
+
*/
|
|
4657
|
+
static scard(key: string): Promise<number>;
|
|
4658
|
+
/**
|
|
4659
|
+
* @description Returns the intersection of multiple sets
|
|
4660
|
+
* @param {string[]} keys - The keys of the sets to intersect
|
|
4661
|
+
* @returns {Promise<T[]>} - Array of members in the intersection
|
|
4662
|
+
*/
|
|
4663
|
+
static sinter<T = RedisFetchable>(...keys: string[]): Promise<T[]>;
|
|
4664
|
+
/**
|
|
4665
|
+
* @description Returns the union of multiple sets
|
|
4666
|
+
* @param {string[]} keys - The keys of the sets to union
|
|
4667
|
+
* @returns {Promise<T[]>} - Array of members in the union
|
|
4668
|
+
*/
|
|
4669
|
+
static sunion<T = RedisFetchable>(...keys: string[]): Promise<T[]>;
|
|
4670
|
+
/**
|
|
4671
|
+
* @description Returns the difference between the first set and all successive sets
|
|
4672
|
+
* @param {string[]} keys - The keys of the sets to diff
|
|
4673
|
+
* @returns {Promise<T[]>} - Array of members in the difference
|
|
4674
|
+
*/
|
|
4675
|
+
static sdiff<T = RedisFetchable>(...keys: string[]): Promise<T[]>;
|
|
4676
|
+
/**
|
|
4677
|
+
* @description Adds one or more members to a set
|
|
4678
|
+
* @param {string} key - The key of the set
|
|
4679
|
+
* @param {RedisStorable[]} members - The members to add
|
|
4680
|
+
* @returns {Promise<number>} - The number of elements added to the set
|
|
4681
|
+
*/
|
|
4682
|
+
sadd(key: string, ...members: RedisStorable[]): Promise<number>;
|
|
4683
|
+
/**
|
|
4684
|
+
* @description Gets all members of a set
|
|
4685
|
+
* @param {string} key - The key of the set
|
|
4686
|
+
* @returns {Promise<T[]>} - Array of set members
|
|
4687
|
+
*/
|
|
4688
|
+
smembers<T = RedisFetchable>(key: string): Promise<T[]>;
|
|
4689
|
+
/**
|
|
4690
|
+
* @description Removes one or more members from a set
|
|
4691
|
+
* @param {string} key - The key of the set
|
|
4692
|
+
* @param {RedisStorable[]} members - The members to remove
|
|
4693
|
+
* @returns {Promise<number>} - The number of members that were removed
|
|
4694
|
+
*/
|
|
4695
|
+
srem(key: string, ...members: RedisStorable[]): Promise<number>;
|
|
4696
|
+
/**
|
|
4697
|
+
* @description Determines whether a member belongs to a set
|
|
4698
|
+
* @param {string} key - The key of the set
|
|
4699
|
+
* @param {RedisStorable} member - The member to check
|
|
4700
|
+
* @returns {Promise<number>} - 1 if the member exists in the set, 0 if not
|
|
4701
|
+
*/
|
|
4702
|
+
sismember(key: string, member: RedisStorable): Promise<number>;
|
|
4703
|
+
/**
|
|
4704
|
+
* @description Gets the number of members in a set
|
|
4705
|
+
* @param {string} key - The key of the set
|
|
4706
|
+
* @returns {Promise<number>} - The number of members in the set
|
|
4707
|
+
*/
|
|
4708
|
+
scard(key: string): Promise<number>;
|
|
4709
|
+
/**
|
|
4710
|
+
* @description Returns the intersection of multiple sets
|
|
4711
|
+
* @param {string[]} keys - The keys of the sets to intersect
|
|
4712
|
+
* @returns {Promise<T[]>} - Array of members in the intersection
|
|
4713
|
+
*/
|
|
4714
|
+
sinter<T = RedisFetchable>(...keys: string[]): Promise<T[]>;
|
|
4715
|
+
/**
|
|
4716
|
+
* @description Returns the union of multiple sets
|
|
4717
|
+
* @param {string[]} keys - The keys of the sets to union
|
|
4718
|
+
* @returns {Promise<T[]>} - Array of members in the union
|
|
4719
|
+
*/
|
|
4720
|
+
sunion<T = RedisFetchable>(...keys: string[]): Promise<T[]>;
|
|
4721
|
+
/**
|
|
4722
|
+
* @description Returns the difference between the first set and all successive sets
|
|
4723
|
+
* @param {string[]} keys - The keys of the sets to diff
|
|
4724
|
+
* @returns {Promise<T[]>} - Array of members in the difference
|
|
4725
|
+
*/
|
|
4726
|
+
sdiff<T = RedisFetchable>(...keys: string[]): Promise<T[]>;
|
|
4727
|
+
/**
|
|
4728
|
+
* @description Adds a member to a sorted set, or updates the score of an existing member
|
|
4729
|
+
* @param {string} key - The key of the sorted set
|
|
4730
|
+
* @param {number} score - The score associated with the member
|
|
4731
|
+
* @param {RedisStorable} member - The member to add or update
|
|
4732
|
+
* @returns {Promise<number>} - The number of new members added to the sorted set
|
|
4733
|
+
*/
|
|
4734
|
+
static zadd(key: string, score: number, member: RedisStorable): Promise<number>;
|
|
4735
|
+
static zadd(key: string, scoreMembers: Array<[number, RedisStorable]>): Promise<number>;
|
|
4736
|
+
/**
|
|
4737
|
+
* @description Gets a range of members from a sorted set, ordered by score
|
|
4738
|
+
* @param {string} key - The key of the sorted set
|
|
4739
|
+
* @param {number} start - The starting index
|
|
4740
|
+
* @param {number} stop - The stopping index
|
|
4741
|
+
* @param {boolean} withScores - Whether to return the scores along with the members
|
|
4742
|
+
* @returns {Promise<T[] | Array<{value: T, score: number}>>} - Array of members or [member, score] pairs
|
|
4743
|
+
*/
|
|
4744
|
+
static zrange<T = RedisFetchable>(key: string, start: number, stop: number, withScores?: boolean): Promise<T[] | Array<{
|
|
4745
|
+
value: T;
|
|
4746
|
+
score: number;
|
|
4747
|
+
}>>;
|
|
4748
|
+
/**
|
|
4749
|
+
* @description Gets a range of members from a sorted set, ordered by score in descending order
|
|
4750
|
+
* @param {string} key - The key of the sorted set
|
|
4751
|
+
* @param {number} start - The starting index
|
|
4752
|
+
* @param {number} stop - The stopping index
|
|
4753
|
+
* @param {boolean} withScores - Whether to return the scores along with the members
|
|
4754
|
+
* @returns {Promise<T[] | Array<{value: T, score: number}>>} - Array of members or [member, score] pairs
|
|
4755
|
+
*/
|
|
4756
|
+
static zrevrange<T = RedisFetchable>(key: string, start: number, stop: number, withScores?: boolean): Promise<T[] | Array<{
|
|
4757
|
+
value: T;
|
|
4758
|
+
score: number;
|
|
4759
|
+
}>>;
|
|
4760
|
+
/**
|
|
4761
|
+
* @description Removes one or more members from a sorted set
|
|
4762
|
+
* @param {string} key - The key of the sorted set
|
|
4763
|
+
* @param {RedisStorable[]} members - The members to remove
|
|
4764
|
+
* @returns {Promise<number>} - The number of members removed
|
|
4765
|
+
*/
|
|
4766
|
+
static zrem(key: string, ...members: RedisStorable[]): Promise<number>;
|
|
4767
|
+
/**
|
|
4768
|
+
* @description Gets the score of a member in a sorted set
|
|
4769
|
+
* @param {string} key - The key of the sorted set
|
|
4770
|
+
* @param {RedisStorable} member - The member to get the score of
|
|
4771
|
+
* @returns {Promise<number | null>} - The score of the member, or null if the member does not exist
|
|
4772
|
+
*/
|
|
4773
|
+
static zscore(key: string, member: RedisStorable): Promise<number | null>;
|
|
4774
|
+
/**
|
|
4775
|
+
* @description Gets the number of members in a sorted set
|
|
4776
|
+
* @param {string} key - The key of the sorted set
|
|
4777
|
+
* @returns {Promise<number>} - The number of members in the sorted set
|
|
4778
|
+
*/
|
|
4779
|
+
static zcard(key: string): Promise<number>;
|
|
4780
|
+
/**
|
|
4781
|
+
* @description Adds a member to a sorted set, or updates the score of an existing member
|
|
4782
|
+
* @param {string} key - The key of the sorted set
|
|
4783
|
+
* @param {number} score - The score associated with the member
|
|
4784
|
+
* @param {RedisStorable} member - The member to add or update
|
|
4785
|
+
* @returns {Promise<number>} - The number of new members added to the sorted set
|
|
4786
|
+
*/
|
|
4787
|
+
zadd(key: string, score: number, member: RedisStorable): Promise<number>;
|
|
4788
|
+
zadd(key: string, scoreMembers: Array<[number, RedisStorable]>): Promise<number>;
|
|
4789
|
+
/**
|
|
4790
|
+
* @description Gets a range of members from a sorted set, ordered by score
|
|
4791
|
+
* @param {string} key - The key of the sorted set
|
|
4792
|
+
* @param {number} start - The starting index
|
|
4793
|
+
* @param {number} stop - The stopping index
|
|
4794
|
+
* @param {boolean} withScores - Whether to return the scores along with the members
|
|
4795
|
+
* @returns {Promise<T[] | Array<{value: T, score: number}>>} - Array of members or [member, score] pairs
|
|
4796
|
+
*/
|
|
4797
|
+
zrange<T = RedisFetchable>(key: string, start: number, stop: number, withScores?: boolean): Promise<T[] | Array<{
|
|
4798
|
+
value: T;
|
|
4799
|
+
score: number;
|
|
4800
|
+
}>>;
|
|
4801
|
+
/**
|
|
4802
|
+
* @description Gets a range of members from a sorted set, ordered by score in descending order
|
|
4803
|
+
* @param {string} key - The key of the sorted set
|
|
4804
|
+
* @param {number} start - The starting index
|
|
4805
|
+
* @param {number} stop - The stopping index
|
|
4806
|
+
* @param {boolean} withScores - Whether to return the scores along with the members
|
|
4807
|
+
* @returns {Promise<T[] | Array<{value: T, score: number}>>} - Array of members or [member, score] pairs
|
|
4808
|
+
*/
|
|
4809
|
+
zrevrange<T = RedisFetchable>(key: string, start: number, stop: number, withScores?: boolean): Promise<T[] | Array<{
|
|
4810
|
+
value: T;
|
|
4811
|
+
score: number;
|
|
4812
|
+
}>>;
|
|
4813
|
+
/**
|
|
4814
|
+
* @description Removes one or more members from a sorted set
|
|
4815
|
+
* @param {string} key - The key of the sorted set
|
|
4816
|
+
* @param {RedisStorable[]} members - The members to remove
|
|
4817
|
+
* @returns {Promise<number>} - The number of members removed
|
|
4818
|
+
*/
|
|
4819
|
+
zrem(key: string, ...members: RedisStorable[]): Promise<number>;
|
|
4820
|
+
/**
|
|
4821
|
+
* @description Gets the score of a member in a sorted set
|
|
4822
|
+
* @param {string} key - The key of the sorted set
|
|
4823
|
+
* @param {RedisStorable} member - The member to get the score of
|
|
4824
|
+
* @returns {Promise<number | null>} - The score of the member, or null if the member does not exist
|
|
4825
|
+
*/
|
|
4826
|
+
zscore(key: string, member: RedisStorable): Promise<number | null>;
|
|
4827
|
+
/**
|
|
4828
|
+
* @description Gets the number of members in a sorted set
|
|
4829
|
+
* @param {string} key - The key of the sorted set
|
|
4830
|
+
* @returns {Promise<number>} - The number of members in the sorted set
|
|
4831
|
+
*/
|
|
4832
|
+
zcard(key: string): Promise<number>;
|
|
4833
|
+
/**
|
|
4834
|
+
* @description Subscribes to one or more channels
|
|
4835
|
+
* @param {string[]} channels - The channels to subscribe to
|
|
4836
|
+
* @param {RedisMessageHandler} handler - The function to call when a message is received
|
|
4837
|
+
* @returns {Promise<void>}
|
|
4838
|
+
*/
|
|
4839
|
+
static subscribe(channels: string[], handler: RedisMessageHandler): Promise<void>;
|
|
4840
|
+
/**
|
|
4841
|
+
* @description Unsubscribes from one or more channels
|
|
4842
|
+
* @param {string[]} channels - The channels to unsubscribe from
|
|
4843
|
+
* @returns {Promise<void>}
|
|
4844
|
+
*/
|
|
4845
|
+
static unsubscribe(...channels: string[]): Promise<void>;
|
|
4846
|
+
/**
|
|
4847
|
+
* @description Publishes a message to a channel
|
|
4848
|
+
* @param {string} channel - The channel to publish to
|
|
4849
|
+
* @param {RedisStorable} message - The message to publish
|
|
4850
|
+
* @returns {Promise<number>} - The number of clients that received the message
|
|
4851
|
+
*/
|
|
4852
|
+
static publish(channel: string, message: RedisStorable): Promise<number>;
|
|
4853
|
+
/**
|
|
4854
|
+
* @description Pattern subscribe to channels
|
|
4855
|
+
* @param {string[]} patterns - The patterns to subscribe to
|
|
4856
|
+
* @param {RedisMessageHandler} handler - The function to call when a message is received
|
|
4857
|
+
* @returns {Promise<void>}
|
|
4858
|
+
*/
|
|
4859
|
+
static psubscribe(patterns: string[], handler: RedisMessageHandler): Promise<void>;
|
|
4860
|
+
/**
|
|
4861
|
+
* @description Pattern unsubscribe from channels
|
|
4862
|
+
* @param {string[]} patterns - The patterns to unsubscribe from
|
|
4863
|
+
* @returns {Promise<void>}
|
|
4864
|
+
*/
|
|
4865
|
+
static punsubscribe(...patterns: string[]): Promise<void>;
|
|
4866
|
+
/**
|
|
4867
|
+
* @description Subscribes to one or more channels
|
|
4868
|
+
* @param {string[]} channels - The channels to subscribe to
|
|
4869
|
+
* @param {RedisMessageHandler} handler - The function to call when a message is received
|
|
4870
|
+
* @returns {Promise<void>}
|
|
4871
|
+
*/
|
|
4872
|
+
subscribe(channels: string[], handler: RedisMessageHandler): Promise<void>;
|
|
4873
|
+
/**
|
|
4874
|
+
* @description Unsubscribes from one or more channels
|
|
4875
|
+
* @param {string[]} channels - The channels to unsubscribe from
|
|
4876
|
+
* @returns {Promise<void>}
|
|
4877
|
+
*/
|
|
4878
|
+
unsubscribe(...channels: string[]): Promise<void>;
|
|
4879
|
+
/**
|
|
4880
|
+
* @description Publishes a message to a channel
|
|
4881
|
+
* @param {string} channel - The channel to publish to
|
|
4882
|
+
* @param {RedisStorable} message - The message to publish
|
|
4883
|
+
* @returns {Promise<number>} - The number of clients that received the message
|
|
4884
|
+
*/
|
|
4885
|
+
publish(channel: string, message: RedisStorable): Promise<number>;
|
|
4886
|
+
/**
|
|
4887
|
+
* @description Pattern subscribe to channels
|
|
4888
|
+
* @param {string[]} patterns - The patterns to subscribe to
|
|
4889
|
+
* @param {RedisMessageHandler} handler - The function to call when a message is received
|
|
4890
|
+
* @returns {Promise<void>}
|
|
4891
|
+
*/
|
|
4892
|
+
psubscribe(patterns: string[], handler: RedisMessageHandler): Promise<void>;
|
|
4893
|
+
/**
|
|
4894
|
+
* @description Pattern unsubscribe from channels
|
|
4895
|
+
* @param {string[]} patterns - The patterns to unsubscribe from
|
|
4896
|
+
* @returns {Promise<void>}
|
|
4897
|
+
*/
|
|
4898
|
+
punsubscribe(...patterns: string[]): Promise<void>;
|
|
4899
|
+
/**
|
|
4900
|
+
* @description Checks if a key exists
|
|
4901
|
+
* @param {string} key - The key to check
|
|
4902
|
+
* @returns {Promise<number>} - 1 if the key exists, 0 if not
|
|
4903
|
+
*/
|
|
4904
|
+
static exists(key: string): Promise<number>;
|
|
4905
|
+
/**
|
|
4906
|
+
* @description Sets the expiration time of a key
|
|
4907
|
+
* @param {string} key - The key to set the expiration for
|
|
4908
|
+
* @param {number} seconds - The expiration time in seconds
|
|
4909
|
+
* @returns {Promise<number>} - 1 if the timeout was set, 0 if not
|
|
4910
|
+
*/
|
|
4911
|
+
static expire(key: string, seconds: number): Promise<number>;
|
|
4912
|
+
/**
|
|
4913
|
+
* @description Sets the expiration time of a key using a UNIX timestamp
|
|
4914
|
+
* @param {string} key - The key to set the expiration for
|
|
4915
|
+
* @param {number} timestamp - UNIX timestamp in seconds
|
|
4916
|
+
* @returns {Promise<number>} - 1 if the timeout was set, 0 if not
|
|
4917
|
+
*/
|
|
4918
|
+
static expireat(key: string, timestamp: number): Promise<number>;
|
|
4919
|
+
/**
|
|
4920
|
+
* @description Sets the expiration time of a key in milliseconds
|
|
4921
|
+
* @param {string} key - The key to set the expiration for
|
|
4922
|
+
* @param {number} milliseconds - The expiration time in milliseconds
|
|
4923
|
+
* @returns {Promise<number>} - 1 if the timeout was set, 0 if not
|
|
4924
|
+
*/
|
|
4925
|
+
static pexpire(key: string, milliseconds: number): Promise<number>;
|
|
4926
|
+
/**
|
|
4927
|
+
* @description Gets the remaining time to live of a key in seconds
|
|
4928
|
+
* @param {string} key - The key to get the TTL for
|
|
4929
|
+
* @returns {Promise<number>} - TTL in seconds, -1 if no expiry, -2 if key doesn't exist
|
|
4930
|
+
*/
|
|
4931
|
+
static ttl(key: string): Promise<number>;
|
|
4932
|
+
/**
|
|
4933
|
+
* @description Gets the remaining time to live of a key in milliseconds
|
|
4934
|
+
* @param {string} key - The key to get the TTL for
|
|
4935
|
+
* @returns {Promise<number>} - TTL in milliseconds, -1 if no expiry, -2 if key doesn't exist
|
|
4936
|
+
*/
|
|
4937
|
+
static pttl(key: string): Promise<number>;
|
|
4938
|
+
/**
|
|
4939
|
+
* @description Removes the expiration time from a key
|
|
4940
|
+
* @param {string} key - The key to persist
|
|
4941
|
+
* @returns {Promise<number>} - 1 if the timeout was removed, 0 if not
|
|
4942
|
+
*/
|
|
4943
|
+
static persist(key: string): Promise<number>;
|
|
4944
|
+
/**
|
|
4945
|
+
* @description Gets all keys matching a pattern
|
|
4946
|
+
* @param {string} pattern - The pattern to match
|
|
4947
|
+
* @returns {Promise<string[]>} - Array of matching keys
|
|
4948
|
+
*/
|
|
4949
|
+
static keys(pattern: string): Promise<string[]>;
|
|
4950
|
+
/**
|
|
4951
|
+
* @description Renames a key
|
|
4952
|
+
* @param {string} key - The key to rename
|
|
4953
|
+
* @param {string} newKey - The new name for the key
|
|
4954
|
+
* @returns {Promise<string>} - "OK" if successful
|
|
4955
|
+
*/
|
|
4956
|
+
static rename(key: string, newKey: string): Promise<string>;
|
|
4957
|
+
/**
|
|
4958
|
+
* @description Returns the type of value stored at a key
|
|
4959
|
+
* @param {string} key - The key to check
|
|
4960
|
+
* @returns {Promise<string>} - Type of key (string, list, set, zset, hash, or none if key doesn't exist)
|
|
4961
|
+
*/
|
|
4962
|
+
static type(key: string): Promise<string>;
|
|
4963
|
+
/**
|
|
4964
|
+
* @description Checks if a key exists
|
|
4965
|
+
* @param {string} key - The key to check
|
|
4966
|
+
* @returns {Promise<number>} - 1 if the key exists, 0 if not
|
|
4967
|
+
*/
|
|
4968
|
+
exists(key: string): Promise<number>;
|
|
4969
|
+
/**
|
|
4970
|
+
* @description Sets the expiration time of a key
|
|
4971
|
+
* @param {string} key - The key to set the expiration for
|
|
4972
|
+
* @param {number} seconds - The expiration time in seconds
|
|
4973
|
+
* @returns {Promise<number>} - 1 if the timeout was set, 0 if not
|
|
4974
|
+
*/
|
|
4975
|
+
expire(key: string, seconds: number): Promise<number>;
|
|
4976
|
+
/**
|
|
4977
|
+
* @description Sets the expiration time of a key using a UNIX timestamp
|
|
4978
|
+
* @param {string} key - The key to set the expiration for
|
|
4979
|
+
* @param {number} timestamp - UNIX timestamp in seconds
|
|
4980
|
+
* @returns {Promise<number>} - 1 if the timeout was set, 0 if not
|
|
4981
|
+
*/
|
|
4982
|
+
expireat(key: string, timestamp: number): Promise<number>;
|
|
4983
|
+
/**
|
|
4984
|
+
* @description Sets the expiration time of a key in milliseconds
|
|
4985
|
+
* @param {string} key - The key to set the expiration for
|
|
4986
|
+
* @param {number} milliseconds - The expiration time in milliseconds
|
|
4987
|
+
* @returns {Promise<number>} - 1 if the timeout was set, 0 if not
|
|
4988
|
+
*/
|
|
4989
|
+
pexpire(key: string, milliseconds: number): Promise<number>;
|
|
4990
|
+
/**
|
|
4991
|
+
* @description Gets the remaining time to live of a key in seconds
|
|
4992
|
+
* @param {string} key - The key to get the TTL for
|
|
4993
|
+
* @returns {Promise<number>} - TTL in seconds, -1 if no expiry, -2 if key doesn't exist
|
|
4994
|
+
*/
|
|
4995
|
+
ttl(key: string): Promise<number>;
|
|
4996
|
+
/**
|
|
4997
|
+
* @description Gets the remaining time to live of a key in milliseconds
|
|
4998
|
+
* @param {string} key - The key to get the TTL for
|
|
4999
|
+
* @returns {Promise<number>} - TTL in milliseconds, -1 if no expiry, -2 if key doesn't exist
|
|
5000
|
+
*/
|
|
5001
|
+
pttl(key: string): Promise<number>;
|
|
5002
|
+
/**
|
|
5003
|
+
* @description Removes the expiration time from a key
|
|
5004
|
+
* @param {string} key - The key to persist
|
|
5005
|
+
* @returns {Promise<number>} - 1 if the timeout was removed, 0 if not
|
|
5006
|
+
*/
|
|
5007
|
+
persist(key: string): Promise<number>;
|
|
5008
|
+
/**
|
|
5009
|
+
* @description Gets all keys matching a pattern
|
|
5010
|
+
* @param {string} pattern - The pattern to match
|
|
5011
|
+
* @returns {Promise<string[]>} - Array of matching keys
|
|
5012
|
+
*/
|
|
5013
|
+
keys(pattern: string): Promise<string[]>;
|
|
5014
|
+
/**
|
|
5015
|
+
* @description Renames a key
|
|
5016
|
+
* @param {string} key - The key to rename
|
|
5017
|
+
* @param {string} newKey - The new name for the key
|
|
5018
|
+
* @returns {Promise<string>} - "OK" if successful
|
|
5019
|
+
*/
|
|
5020
|
+
rename(key: string, newKey: string): Promise<string>;
|
|
5021
|
+
/**
|
|
5022
|
+
* @description Returns the type of value stored at a key
|
|
5023
|
+
* @param {string} key - The key to check
|
|
5024
|
+
* @returns {Promise<string>} - Type of key (string, list, set, zset, hash, or none if key doesn't exist)
|
|
5025
|
+
*/
|
|
5026
|
+
type(key: string): Promise<string>;
|
|
4279
5027
|
protected static getValue<T = RedisFetchable>(value: string | null): T | null;
|
|
4280
5028
|
}
|
|
4281
5029
|
|
|
@@ -4346,9 +5094,9 @@ type WithPerformanceResult<R = any> = [string, R];
|
|
|
4346
5094
|
* @param `fix` Number of digits in the decimal part of the performance result
|
|
4347
5095
|
* @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
5096
|
*/
|
|
4349
|
-
declare const withPerformance: <
|
|
5097
|
+
declare const withPerformance: <A extends any[], R>(fn: (...args: A) => Promise<R>, returnType?: "millis" | "seconds", fix?: number) => (...args: A) => Promise<WithPerformanceResult<R>>;
|
|
4350
5098
|
|
|
4351
|
-
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";
|
|
5099
|
+
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" | "LPUSH_FAILED" | "RPUSH_FAILED" | "LPOP_FAILED" | "RPOP_FAILED" | "LRANGE_FAILED" | "LLEN_FAILED" | "HSET_FAILED" | "HMSET_FAILED" | "HGET_FAILED" | "HGETALL_FAILED" | "HMGET_FAILED" | "HDEL_FAILED" | "HEXISTS_FAILED" | "HKEYS_FAILED" | "HLEN_FAILED" | "SADD_FAILED" | "SMEMBERS_FAILED" | "SREM_FAILED" | "SISMEMBER_FAILED" | "SCARD_FAILED" | "SINTER_FAILED" | "SUNION_FAILED" | "SDIFF_FAILED" | "ZADD_FAILED" | "ZRANGE_FAILED" | "ZREVRANGE_FAILED" | "ZREM_FAILED" | "ZSCORE_FAILED" | "ZCARD_FAILED" | "SUBSCRIBE_FAILED" | "UNSUBSCRIBE_FAILED" | "PUBLISH_FAILED" | "PSUBSCRIBE_FAILED" | "PUNSUBSCRIBE_FAILED" | "EXISTS_FAILED" | "EXPIRE_FAILED" | "EXPIREAT_FAILED" | "PEXPIRE_FAILED" | "TTL_FAILED" | "PTTL_FAILED" | "PERSIST_FAILED" | "KEYS_FAILED" | "RENAME_FAILED" | "TYPE_FAILED" | "SCAN_FAILED";
|
|
4352
5100
|
|
|
4353
5101
|
declare class HysteriaError extends Error {
|
|
4354
5102
|
code: HysteriaErrorCode;
|
|
@@ -4372,4 +5120,4 @@ declare const generateOpenApiModelWithMetadata: <T extends new () => Model>(mode
|
|
|
4372
5120
|
modelName: string;
|
|
4373
5121
|
}>;
|
|
4374
5122
|
|
|
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 };
|
|
5123
|
+
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 TableFormat, 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 };
|