hysteria-orm 11.0.0 → 11.0.1
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.js +2 -2
- package/lib/cli.js.map +1 -1
- package/lib/index.cjs +31 -31
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +201 -418
- package/lib/index.d.ts +201 -418
- package/lib/index.js +31 -31
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/index.d.cts
CHANGED
|
@@ -213,7 +213,7 @@ declare class RawNode extends QueryNode {
|
|
|
213
213
|
}
|
|
214
214
|
|
|
215
215
|
type BaseValues$2 = string | number | boolean | undefined | null | RawNode;
|
|
216
|
-
type BinaryOperatorType$2 = "=" | "!=" | "<>" | ">" | "<" | ">=" | "<=" | "is" | "is not" | "like" | "not like" | "is null" | "is not null" | "ilike" | "in" | "not in" | "between" | "not between" | "regexp" | "not regexp" | "not ilike";
|
|
216
|
+
type BinaryOperatorType$2 = "=" | "!=" | "<>" | ">" | "<" | ">=" | "<=" | "is" | "is not" | "like" | "not like" | "is null" | "is not null" | "ilike" | "in" | "not in" | "between" | "not between" | "regexp" | "not regexp" | "not ilike" | (string & {});
|
|
217
217
|
declare class WhereNode extends QueryNode {
|
|
218
218
|
column: string;
|
|
219
219
|
isNegated: boolean;
|
|
@@ -840,6 +840,11 @@ type SqlDataSourceInputBase<T extends Record<string, SqlDataSourceModel> = {}, C
|
|
|
840
840
|
* @description To use AdminJS, install: `npm install adminjs`
|
|
841
841
|
*/
|
|
842
842
|
adminJs?: AdminJsOptions;
|
|
843
|
+
/**
|
|
844
|
+
* @description If true, the data source will not throw when unconnected — it will auto-connect on the first query execution.
|
|
845
|
+
* @default false
|
|
846
|
+
*/
|
|
847
|
+
lazyLoad?: boolean;
|
|
843
848
|
};
|
|
844
849
|
/**
|
|
845
850
|
* @description Maps a SqlDataSourceType to its corresponding input interface
|
|
@@ -1970,6 +1975,79 @@ declare class ModelManager<T extends Model> {
|
|
|
1970
1975
|
}
|
|
1971
1976
|
|
|
1972
1977
|
type JsonPathInput = string | (string | number)[];
|
|
1978
|
+
/**
|
|
1979
|
+
* Recursively generates all valid dot-separated JSON path strings from an
|
|
1980
|
+
* object type `T`.
|
|
1981
|
+
*
|
|
1982
|
+
* Handles nested objects, arrays (via numeric indices), and stops recursion at
|
|
1983
|
+
* a configurable depth (default 5) to prevent infinite expansion with deeply
|
|
1984
|
+
* nested or self-referential types.
|
|
1985
|
+
*
|
|
1986
|
+
* @typeParam T - The root object type to extract paths from.
|
|
1987
|
+
*
|
|
1988
|
+
* @example
|
|
1989
|
+
* ```ts
|
|
1990
|
+
* type Data = { user: { name: string; roles: string[] }; count: number };
|
|
1991
|
+
* type P = JsonPaths<Data>;
|
|
1992
|
+
* // "user" | "user.name" | "user.roles" | "user.roles.${number}" | "count"
|
|
1993
|
+
* ```
|
|
1994
|
+
*/
|
|
1995
|
+
type JsonPaths<T, Depth extends number[] = []> = Depth["length"] extends 5 ? never : T extends readonly (infer E)[] ? `${number}` | (NonNullable<E> extends object ? `${number}.${JsonPaths<NonNullable<E>, [...Depth, 1]>}` : never) : T extends object ? {
|
|
1996
|
+
[K in keyof T & string]: K | (NonNullable<T[K]> extends object ? `${K}.${JsonPaths<NonNullable<T[K]>, [...Depth, 1]>}` : never);
|
|
1997
|
+
}[keyof T & string] : never;
|
|
1998
|
+
/**
|
|
1999
|
+
* Resolves the TypeScript type of a model column given its `ModelKey` string.
|
|
2000
|
+
* Strips any table prefix (e.g. `"users.metadata"` → `"metadata"`) before
|
|
2001
|
+
* indexing into the model.
|
|
2002
|
+
*
|
|
2003
|
+
* @typeParam T - The Model instance type.
|
|
2004
|
+
* @typeParam K - The column key (plain or table-prefixed).
|
|
2005
|
+
*/
|
|
2006
|
+
type ResolveColumnType<T extends Model, K extends string> = T[StripTablePrefix<K> & keyof T];
|
|
2007
|
+
/**
|
|
2008
|
+
* Type-safe JSON path input that provides IDE autocompletion for known JSON
|
|
2009
|
+
* column structures while still accepting arbitrary strings as a fallback.
|
|
2010
|
+
*
|
|
2011
|
+
* - When `ColumnType` is a known object/array type: suggests all valid
|
|
2012
|
+
* dot-separated paths via {@link JsonPaths}, plus `(string & {})` as a
|
|
2013
|
+
* catch-all and `(string | number)[]` for the array form.
|
|
2014
|
+
* - When `ColumnType` is `unknown`, a primitive, or `never`: falls back to the
|
|
2015
|
+
* original untyped {@link JsonPathInput}.
|
|
2016
|
+
*
|
|
2017
|
+
* Uses the `SpecificLiteral | (string & {})` pattern so TypeScript's
|
|
2018
|
+
* autocomplete shows the known paths first without blocking custom strings.
|
|
2019
|
+
*
|
|
2020
|
+
* @typeParam ColumnType - The TypeScript type of the JSON column value.
|
|
2021
|
+
*
|
|
2022
|
+
* @example
|
|
2023
|
+
* ```ts
|
|
2024
|
+
* type Settings = { theme: string; notifications: { email: boolean } };
|
|
2025
|
+
* type P = TypedJsonPathInput<Settings | null>;
|
|
2026
|
+
* // "theme" | "notifications" | "notifications.email" | (string & {}) | (string | number)[]
|
|
2027
|
+
* ```
|
|
2028
|
+
*/
|
|
2029
|
+
/**
|
|
2030
|
+
* Resolves the TypeScript type at a given dot-separated JSON path within a
|
|
2031
|
+
* root type. Handles `$` prefix, dot notation, and array numeric indices.
|
|
2032
|
+
*
|
|
2033
|
+
* Falls back to `unknown` when the path does not match the type structure.
|
|
2034
|
+
*
|
|
2035
|
+
* @typeParam T - The root JSON object type to traverse.
|
|
2036
|
+
* @typeParam Path - A dot-separated string path.
|
|
2037
|
+
*
|
|
2038
|
+
* @example
|
|
2039
|
+
* ```ts
|
|
2040
|
+
* type Data = { user: { name: string; roles: string[] } };
|
|
2041
|
+
* type A = ResolveJsonPathType<Data, "user.name">; // string
|
|
2042
|
+
* type B = ResolveJsonPathType<Data, "user.roles">; // string[]
|
|
2043
|
+
* type C = ResolveJsonPathType<Data, "user">; // { name: string; roles: string[] }
|
|
2044
|
+
* type D = ResolveJsonPathType<Data, "$">; // Data
|
|
2045
|
+
* ```
|
|
2046
|
+
*/
|
|
2047
|
+
type ResolveJsonPathType<T, Path extends string> = Path extends `$.${infer Rest}` ? ResolveJsonPathType<T, Rest> : Path extends "$" | "" ? T : Path extends `${infer Head}.${infer Rest}` ? Head extends keyof NonNullable<T> ? ResolveJsonPathType<NonNullable<T>[Head], Rest> : NonNullable<T> extends readonly (infer E)[] ? Head extends `${number}` ? ResolveJsonPathType<E, Rest> : unknown : unknown : Path extends keyof NonNullable<T> ? NonNullable<T>[Path] : NonNullable<T> extends readonly (infer E)[] ? Path extends `${number}` ? E : unknown : unknown;
|
|
2048
|
+
type TypedJsonPathInput<ColumnType> = [NonNullable<ColumnType>] extends [
|
|
2049
|
+
never
|
|
2050
|
+
] ? JsonPathInput : unknown extends NonNullable<ColumnType> ? JsonPathInput : NonNullable<ColumnType> extends object ? JsonPaths<NonNullable<ColumnType>> | (string & {}) | (string | number)[] : JsonPathInput;
|
|
1973
2051
|
|
|
1974
2052
|
declare class DeleteNode extends QueryNode {
|
|
1975
2053
|
fromNode: FromNode;
|
|
@@ -2107,6 +2185,8 @@ declare class MongoQueryBuilder<T extends Collection> {
|
|
|
2107
2185
|
protected logs: boolean | LoggerConfig;
|
|
2108
2186
|
protected session?: ReturnType<MongoDataSource["startSession"]>;
|
|
2109
2187
|
constructor(model: typeof Collection, mongoDataSource: MongoDataSource, _session?: ReturnType<MongoDataSource["startSession"]>, logs?: boolean | LoggerConfig);
|
|
2188
|
+
private initCollection;
|
|
2189
|
+
protected ensureInitialized(): Promise<void>;
|
|
2110
2190
|
one(options?: OneOptions$1): Promise<T | null>;
|
|
2111
2191
|
oneOrFail(options?: OneOptions$1): Promise<T>;
|
|
2112
2192
|
many(options?: ManyOptions$1): Promise<T[]>;
|
|
@@ -2414,6 +2494,8 @@ declare class CollectionManager<T extends Collection> {
|
|
|
2414
2494
|
protected collectionInstance: MongoClientImport["Collection"]["prototype"];
|
|
2415
2495
|
protected session?: ReturnType<MongoDataSource["startSession"]>;
|
|
2416
2496
|
constructor(_collection: typeof Collection, mongoDataSource: MongoDataSource, session?: ReturnType<MongoDataSource["startSession"]>, logs?: boolean | LoggerConfig);
|
|
2497
|
+
private initConnection;
|
|
2498
|
+
protected ensureInitialized(): Promise<void>;
|
|
2417
2499
|
/**
|
|
2418
2500
|
* @description Finds all records that match the input
|
|
2419
2501
|
*/
|
|
@@ -2460,17 +2542,24 @@ interface MongoDataSourceInput {
|
|
|
2460
2542
|
url?: string;
|
|
2461
2543
|
options?: MongoConnectionOptions;
|
|
2462
2544
|
logs?: boolean | LoggerConfig;
|
|
2545
|
+
lazyLoad?: boolean;
|
|
2463
2546
|
}
|
|
2464
2547
|
declare class MongoDataSource extends DataSource {
|
|
2465
2548
|
url: string;
|
|
2466
2549
|
isConnected: boolean;
|
|
2467
2550
|
private mongoClient;
|
|
2468
2551
|
private mongoOptions?;
|
|
2552
|
+
private lazyLoad;
|
|
2553
|
+
private connecting;
|
|
2469
2554
|
constructor(input?: MongoDataSourceInput);
|
|
2470
2555
|
/**
|
|
2471
2556
|
* @description Establishes the connection to MongoDB
|
|
2472
2557
|
*/
|
|
2473
2558
|
connect(): Promise<void>;
|
|
2559
|
+
/**
|
|
2560
|
+
* @description Ensures the connection is established. If lazyLoad is true and not connected, connects automatically.
|
|
2561
|
+
*/
|
|
2562
|
+
ensureConnected(): Promise<void>;
|
|
2474
2563
|
/**
|
|
2475
2564
|
* @description Returns the current connection to the mongo client to execute direct statements using the mongo client from `mongodb` package
|
|
2476
2565
|
*/
|
|
@@ -2488,17 +2577,15 @@ declare class MongoDataSource extends DataSource {
|
|
|
2488
2577
|
* @alias disconnect
|
|
2489
2578
|
*/
|
|
2490
2579
|
closeConnection(): Promise<void>;
|
|
2491
|
-
/**
|
|
2492
|
-
* @description Returns a raw MongoQueryBuilder for a collection name string
|
|
2493
|
-
*/
|
|
2494
|
-
query(collectionName: string): MongoQueryBuilder<Collection>;
|
|
2495
2580
|
/**
|
|
2496
2581
|
* @description Returns a CollectionManager for the given collection class,
|
|
2497
2582
|
* providing query(), find(), findOne(), insert(), etc.
|
|
2583
|
+
* When a string is passed, returns a raw MongoQueryBuilder for the collection name.
|
|
2498
2584
|
*/
|
|
2499
2585
|
from<T extends Collection>(collection: (new (...args: any[]) => T) & Record<string, any>, options?: {
|
|
2500
2586
|
session?: InstanceType<MongoClientImport["ClientSession"]>;
|
|
2501
2587
|
}): CollectionManager<T>;
|
|
2588
|
+
from(collectionName: string): MongoQueryBuilder<Collection>;
|
|
2502
2589
|
getModelManager<T extends Collection>(model: typeof Collection, mongoDataSource: MongoDataSource, session?: InstanceType<MongoClientImport["ClientSession"]>): CollectionManager<T>;
|
|
2503
2590
|
}
|
|
2504
2591
|
|
|
@@ -2543,7 +2630,7 @@ declare class HavingNode extends QueryNode {
|
|
|
2543
2630
|
constructor(column: string, chainsWith: "and" | "or", isNegated: boolean | undefined, operator: BinaryOperatorType, value: BaseValues | BaseValues[], isRawValue?: boolean);
|
|
2544
2631
|
}
|
|
2545
2632
|
|
|
2546
|
-
type SubqueryOperatorType = "in" | "not in" | "exists" | "not exists" | "between" | "not between" | ">" | "<" | ">=" | "<=";
|
|
2633
|
+
type SubqueryOperatorType = "in" | "not in" | "exists" | "not exists" | "between" | "not between" | ">" | "<" | ">=" | "<=" | (string & {});
|
|
2547
2634
|
declare class WhereSubqueryNode extends QueryNode {
|
|
2548
2635
|
column: string;
|
|
2549
2636
|
operator: SubqueryOperatorType;
|
|
@@ -3344,27 +3431,52 @@ declare class SelectQueryBuilder<T extends Model, S extends Record<string, any>
|
|
|
3344
3431
|
distinctOn(...columns: ModelKey<T>[]): this;
|
|
3345
3432
|
distinctOn<C extends string>(...columns: SelectableColumn<C>[]): this;
|
|
3346
3433
|
/**
|
|
3347
|
-
* @description Selects a JSON value at the specified path and returns it as JSON
|
|
3434
|
+
* @description Selects a JSON value at the specified path and returns it as JSON.
|
|
3435
|
+
* @description Path format is standardized across all databases — the ORM converts to DB-specific syntax.
|
|
3436
|
+
* @param column - The column containing JSON data (model column name or raw string).
|
|
3437
|
+
* @param path - The JSON path to extract. Accepts dot notation (`"user.name"`), `$`-prefixed
|
|
3438
|
+
* paths (`"$.user.name"`), or an array of segments (`["user", "name"]`).
|
|
3439
|
+
* When the column has a typed JSON schema, IDE autocompletion suggests valid paths.
|
|
3440
|
+
* @param alias - The alias for the extracted value in the result set.
|
|
3348
3441
|
*/
|
|
3349
|
-
selectJson<A extends string>(column:
|
|
3442
|
+
selectJson<K extends ModelKey<T>, A extends string>(column: K, path: TypedJsonPathInput<ResolveColumnType<T, K & string>>, alias: A): this;
|
|
3350
3443
|
selectJson<A extends string>(column: string, path: JsonPathInput, alias: A): this;
|
|
3351
3444
|
/**
|
|
3352
|
-
* @description Selects a JSON value at the specified path and returns it as text
|
|
3445
|
+
* @description Selects a JSON value at the specified path and returns it as text.
|
|
3446
|
+
* @description Path format is standardized across all databases — the ORM converts to DB-specific syntax.
|
|
3447
|
+
* @param column - The column containing JSON data (model column name or raw string).
|
|
3448
|
+
* @param path - The JSON path to extract. Accepts dot notation (`"user.name"`), `$`-prefixed
|
|
3449
|
+
* paths (`"$.user.name"`), or an array of segments (`["user", "name"]`).
|
|
3450
|
+
* When the column has a typed JSON schema, IDE autocompletion suggests valid paths.
|
|
3451
|
+
* @param alias - The alias for the extracted text value in the result set.
|
|
3353
3452
|
*/
|
|
3354
|
-
selectJsonText<A extends string>(column:
|
|
3453
|
+
selectJsonText<K extends ModelKey<T>, A extends string>(column: K, path: TypedJsonPathInput<ResolveColumnType<T, K & string>>, alias: A): this;
|
|
3355
3454
|
selectJsonText<A extends string>(column: string, path: JsonPathInput, alias: A): this;
|
|
3356
3455
|
/**
|
|
3357
|
-
* @description Selects the length of a JSON array
|
|
3456
|
+
* @description Selects the length of a JSON array at the specified path.
|
|
3457
|
+
* @description Path format is standardized across all databases — the ORM converts to DB-specific syntax.
|
|
3458
|
+
* @param column - The column containing JSON array data (model column name or raw string).
|
|
3459
|
+
* @param path - The JSON path to the array. Use `"$"` or `""` for the root array.
|
|
3460
|
+
* When the column has a typed JSON schema, IDE autocompletion suggests valid paths.
|
|
3461
|
+
* @param alias - The alias for the array length value in the result set.
|
|
3358
3462
|
*/
|
|
3359
|
-
selectJsonArrayLength<A extends string>(column:
|
|
3463
|
+
selectJsonArrayLength<K extends ModelKey<T>, A extends string>(column: K, path: TypedJsonPathInput<ResolveColumnType<T, K & string>>, alias: A): this;
|
|
3360
3464
|
selectJsonArrayLength<A extends string>(column: string, path: JsonPathInput, alias: A): this;
|
|
3361
3465
|
/**
|
|
3362
|
-
* @description Selects the keys of a JSON object
|
|
3466
|
+
* @description Selects the keys of a JSON object at the specified path.
|
|
3467
|
+
* @description Path format is standardized across all databases — the ORM converts to DB-specific syntax.
|
|
3468
|
+
* @param column - The column containing JSON object data (model column name or raw string).
|
|
3469
|
+
* @param path - The JSON path to the object. Use `"$"` or `""` for the root object.
|
|
3470
|
+
* When the column has a typed JSON schema, IDE autocompletion suggests valid paths.
|
|
3471
|
+
* @param alias - The alias for the keys array in the result set.
|
|
3363
3472
|
*/
|
|
3364
|
-
selectJsonKeys<A extends string>(column:
|
|
3473
|
+
selectJsonKeys<K extends ModelKey<T>, A extends string>(column: K, path: TypedJsonPathInput<ResolveColumnType<T, K & string>>, alias: A): this;
|
|
3365
3474
|
selectJsonKeys<A extends string>(column: string, path: JsonPathInput, alias: A): this;
|
|
3366
3475
|
/**
|
|
3367
|
-
* @description Adds a raw JSON select expression
|
|
3476
|
+
* @description Adds a raw JSON select expression using database-specific SQL syntax.
|
|
3477
|
+
* @description Bypasses path standardization — you must write DB-specific SQL.
|
|
3478
|
+
* @param raw - The raw SQL expression (e.g., `"data->>'email'"` for PostgreSQL).
|
|
3479
|
+
* @param alias - The alias for the result in the result set.
|
|
3368
3480
|
*/
|
|
3369
3481
|
selectJsonRaw<A extends string>(raw: string, alias: A): this;
|
|
3370
3482
|
}
|
|
@@ -4553,6 +4665,8 @@ declare class SqlDataSource<D extends SqlDataSourceType = SqlDataSourceType, T e
|
|
|
4553
4665
|
* @description Callback to handle slave server failures
|
|
4554
4666
|
*/
|
|
4555
4667
|
private onSlaveServerFailure?;
|
|
4668
|
+
private lazyLoad;
|
|
4669
|
+
private connecting;
|
|
4556
4670
|
/**
|
|
4557
4671
|
* @description Returns the configured slave failure callback
|
|
4558
4672
|
*/
|
|
@@ -4607,6 +4721,10 @@ declare class SqlDataSource<D extends SqlDataSourceType = SqlDataSourceType, T e
|
|
|
4607
4721
|
* @description Returns true if the connection is established
|
|
4608
4722
|
*/
|
|
4609
4723
|
get isConnected(): boolean;
|
|
4724
|
+
/**
|
|
4725
|
+
* @description Ensures the connection is established. If lazyLoad is true and not connected, connects automatically.
|
|
4726
|
+
*/
|
|
4727
|
+
ensureConnected(): Promise<void>;
|
|
4610
4728
|
/**
|
|
4611
4729
|
* @description Returns true if this instance is in a global transaction
|
|
4612
4730
|
*/
|
|
@@ -6039,12 +6157,16 @@ declare class ModelQueryBuilder<T extends Model, S extends Record<string, any> =
|
|
|
6039
6157
|
*/
|
|
6040
6158
|
clearSelect(): ModelQueryBuilder<T, ModelWithoutRelations<T>, R>;
|
|
6041
6159
|
/**
|
|
6042
|
-
* @description Selects a JSON value at the specified path and returns it as JSON
|
|
6043
|
-
* @param column The column containing JSON data
|
|
6044
|
-
*
|
|
6045
|
-
* @param
|
|
6046
|
-
*
|
|
6047
|
-
*
|
|
6160
|
+
* @description Selects a JSON value at the specified path and returns it as JSON.
|
|
6161
|
+
* @param column - The column containing JSON data. Accepts model column names (with IDE autocompletion)
|
|
6162
|
+
* or raw column strings for joins/aliases.
|
|
6163
|
+
* @param path - The JSON path to extract. Accepts dot notation (`"user.name"`), `$`-prefixed paths
|
|
6164
|
+
* (`"$.user.name"`), or an array of segments (`["user", "name"]`).
|
|
6165
|
+
* When the column has a typed JSON schema (e.g. `col.jsonb<{ user: { name: string } }>()`),
|
|
6166
|
+
* IDE autocompletion suggests valid paths into the JSON structure.
|
|
6167
|
+
* @param alias - The alias for the extracted value. The result is available as a typed property
|
|
6168
|
+
* on the returned model with this alias name.
|
|
6169
|
+
* @description Path format is standardized across all databases - ORM converts to DB-specific syntax.
|
|
6048
6170
|
* @example
|
|
6049
6171
|
* ```ts
|
|
6050
6172
|
* // All these path formats are supported:
|
|
@@ -6072,16 +6194,19 @@ declare class ModelQueryBuilder<T extends Model, S extends Record<string, any> =
|
|
|
6072
6194
|
* console.log(user?.userName); // Typed as string
|
|
6073
6195
|
* ```
|
|
6074
6196
|
*/
|
|
6075
|
-
selectJson<
|
|
6076
|
-
[
|
|
6197
|
+
selectJson<K extends ModelKey<T> | (string & {}), P extends [K] extends [ModelKey<T>] ? TypedJsonPathInput<ResolveColumnType<T, K & string>> : JsonPathInput, Alias extends string = string>(column: K, path: P, alias: Alias): ModelQueryBuilder<T, ComposeSelect<S, {
|
|
6198
|
+
[Q in Alias]: [K] extends [ModelKey<T>] ? P extends string ? ResolveJsonPathType<NonNullable<ResolveColumnType<T, K & string>>, P> extends infer R ? unknown extends R ? any : R : any : any : any;
|
|
6077
6199
|
}>, R>;
|
|
6078
6200
|
/**
|
|
6079
|
-
* @description Selects a JSON value at the specified path and returns it as text
|
|
6080
|
-
* @param column The column containing JSON data
|
|
6081
|
-
*
|
|
6082
|
-
* @param
|
|
6083
|
-
*
|
|
6084
|
-
*
|
|
6201
|
+
* @description Selects a JSON value at the specified path and returns it as text.
|
|
6202
|
+
* @param column - The column containing JSON data. Accepts model column names (with IDE autocompletion)
|
|
6203
|
+
* or raw column strings for joins/aliases.
|
|
6204
|
+
* @param path - The JSON path to extract. Accepts dot notation (`"user.email"`), `$`-prefixed paths
|
|
6205
|
+
* (`"$.user.email"`), or an array of segments (`["user", "email"]`).
|
|
6206
|
+
* When the column has a typed JSON schema, IDE autocompletion suggests valid paths.
|
|
6207
|
+
* @param alias - The alias for the extracted text value. The result is available as a typed property
|
|
6208
|
+
* on the returned model with this alias name.
|
|
6209
|
+
* @description Path format is standardized across all databases - ORM converts to DB-specific syntax.
|
|
6085
6210
|
* @example
|
|
6086
6211
|
* ```ts
|
|
6087
6212
|
* // All these path formats are supported:
|
|
@@ -6107,17 +6232,19 @@ declare class ModelQueryBuilder<T extends Model, S extends Record<string, any> =
|
|
|
6107
6232
|
* console.log(user?.userEmail); // Typed as string
|
|
6108
6233
|
* ```
|
|
6109
6234
|
*/
|
|
6110
|
-
selectJsonText<ValueType = string, Alias extends string = string>(column: ModelKey<T>
|
|
6111
|
-
[
|
|
6235
|
+
selectJsonText<K extends ModelKey<T> | (string & {}), ValueType = string, Alias extends string = string>(column: K, path: K extends ModelKey<T> ? TypedJsonPathInput<ResolveColumnType<T, K & string>> : JsonPathInput, alias: Alias): ModelQueryBuilder<T, ComposeSelect<S, {
|
|
6236
|
+
[P in Alias]: ValueType;
|
|
6112
6237
|
}>, R>;
|
|
6113
6238
|
/**
|
|
6114
|
-
* @description Selects the length of a JSON array
|
|
6115
|
-
* @param column The column containing JSON array data
|
|
6116
|
-
*
|
|
6117
|
-
* @param
|
|
6118
|
-
*
|
|
6119
|
-
* @
|
|
6120
|
-
*
|
|
6239
|
+
* @description Selects the length of a JSON array at the specified path.
|
|
6240
|
+
* @param column - The column containing JSON array data. Accepts model column names (with IDE autocompletion)
|
|
6241
|
+
* or raw column strings for joins/aliases.
|
|
6242
|
+
* @param path - The JSON path to the array. Use `"$"` or `""` for root.
|
|
6243
|
+
* When the column has a typed JSON schema, IDE autocompletion suggests valid paths.
|
|
6244
|
+
* @param alias - The alias for the array length value. The result is available as a typed property
|
|
6245
|
+
* on the returned model with this alias name.
|
|
6246
|
+
* @description Path format is standardized across all databases - ORM converts to DB-specific syntax.
|
|
6247
|
+
* @warning Not supported in SQLite.
|
|
6121
6248
|
* @example
|
|
6122
6249
|
* ```ts
|
|
6123
6250
|
* // All these path formats are supported:
|
|
@@ -6147,19 +6274,21 @@ declare class ModelQueryBuilder<T extends Model, S extends Record<string, any> =
|
|
|
6147
6274
|
* console.log(user?.count); // Typed as number
|
|
6148
6275
|
* ```
|
|
6149
6276
|
*/
|
|
6150
|
-
selectJsonArrayLength<ValueType = number, Alias extends string = string>(column: ModelKey<T>
|
|
6151
|
-
[
|
|
6277
|
+
selectJsonArrayLength<K extends ModelKey<T> | (string & {}), ValueType = number, Alias extends string = string>(column: K, path: K extends ModelKey<T> ? TypedJsonPathInput<ResolveColumnType<T, K & string>> : JsonPathInput, alias: Alias): ModelQueryBuilder<T, ComposeSelect<S, {
|
|
6278
|
+
[P in Alias]: ValueType;
|
|
6152
6279
|
}>, R>;
|
|
6153
6280
|
/**
|
|
6154
|
-
* @description Selects the keys of a JSON object
|
|
6155
|
-
* @param column The column containing JSON object data
|
|
6156
|
-
*
|
|
6157
|
-
* @param
|
|
6158
|
-
*
|
|
6159
|
-
* @
|
|
6160
|
-
*
|
|
6161
|
-
* @
|
|
6162
|
-
* @
|
|
6281
|
+
* @description Selects the keys of a JSON object at the specified path.
|
|
6282
|
+
* @param column - The column containing JSON object data. Accepts model column names (with IDE autocompletion)
|
|
6283
|
+
* or raw column strings for joins/aliases.
|
|
6284
|
+
* @param path - The JSON path to the object. Use `"$"` or `""` for root.
|
|
6285
|
+
* When the column has a typed JSON schema, IDE autocompletion suggests valid paths.
|
|
6286
|
+
* @param alias - The alias for the keys array. The result is available as a typed property
|
|
6287
|
+
* on the returned model with this alias name.
|
|
6288
|
+
* @description Path format is standardized across all databases - ORM converts to DB-specific syntax.
|
|
6289
|
+
* @warning Not supported in SQLite or MSSQL.
|
|
6290
|
+
* @postgresql Returns a native array of keys.
|
|
6291
|
+
* @mysql Returns a JSON array of keys.
|
|
6163
6292
|
* @example
|
|
6164
6293
|
* ```ts
|
|
6165
6294
|
* // All these path formats are supported:
|
|
@@ -6189,16 +6318,18 @@ declare class ModelQueryBuilder<T extends Model, S extends Record<string, any> =
|
|
|
6189
6318
|
* console.log(user?.keys); // Typed as string[] - ["theme", "fontSize", "autoSave"]
|
|
6190
6319
|
* ```
|
|
6191
6320
|
*/
|
|
6192
|
-
selectJsonKeys<ValueType = string[], Alias extends string = string>(column: ModelKey<T>
|
|
6193
|
-
[
|
|
6321
|
+
selectJsonKeys<K extends ModelKey<T> | (string & {}), ValueType = string[], Alias extends string = string>(column: K, path: K extends ModelKey<T> ? TypedJsonPathInput<ResolveColumnType<T, K & string>> : JsonPathInput, alias: Alias): ModelQueryBuilder<T, ComposeSelect<S, {
|
|
6322
|
+
[P in Alias]: ValueType;
|
|
6194
6323
|
}>, R>;
|
|
6195
6324
|
/**
|
|
6196
|
-
* @description Adds a raw JSON select expression
|
|
6197
|
-
* @param raw The raw SQL expression (database-specific syntax)
|
|
6198
|
-
*
|
|
6199
|
-
*
|
|
6200
|
-
* @
|
|
6201
|
-
*
|
|
6325
|
+
* @description Adds a raw JSON select expression using database-specific SQL syntax.
|
|
6326
|
+
* @param raw - The raw SQL expression (database-specific syntax). Bypasses path standardization —
|
|
6327
|
+
* you must write DB-specific SQL (e.g., `"data->>'email'"` for PostgreSQL,
|
|
6328
|
+
* `"json_extract(data, '$.email')"` for SQLite).
|
|
6329
|
+
* @param alias - The alias for the extracted value. The result is available as a typed property
|
|
6330
|
+
* on the returned model with this alias name.
|
|
6331
|
+
* @description Use this for advanced JSON operations not covered by other selectJson* methods.
|
|
6332
|
+
* @warning This bypasses path standardization - you must write database-specific SQL.
|
|
6202
6333
|
* @example
|
|
6203
6334
|
* ```ts
|
|
6204
6335
|
* // PostgreSQL - Extract as text with ->> operator
|
|
@@ -7290,79 +7421,33 @@ type RedisFetchable = string | number | boolean | Record<string, any> | Array<an
|
|
|
7290
7421
|
* @description Type for Redis message handler callback
|
|
7291
7422
|
*/
|
|
7292
7423
|
type RedisMessageHandler = (channel: string, message: string) => void;
|
|
7424
|
+
interface RedisDataSourceInput extends RedisOptions {
|
|
7425
|
+
lazyLoad?: boolean;
|
|
7426
|
+
}
|
|
7293
7427
|
/**
|
|
7294
7428
|
* @description The RedisDataSource class is a wrapper around the ioredis library that provides a simple interface to interact with a redis database
|
|
7295
7429
|
*/
|
|
7296
7430
|
declare class RedisDataSource {
|
|
7297
|
-
static readonly OK = "OK";
|
|
7298
7431
|
readonly OK = "OK";
|
|
7299
|
-
static isConnected: boolean;
|
|
7300
|
-
protected static redisDataSourceInstance: RedisDataSource;
|
|
7301
7432
|
isConnected: boolean;
|
|
7302
|
-
protected ioRedisConnection: Redis;
|
|
7303
|
-
|
|
7304
|
-
|
|
7305
|
-
|
|
7306
|
-
|
|
7307
|
-
*/
|
|
7308
|
-
static get ioredis(): Redis;
|
|
7433
|
+
protected ioRedisConnection: Redis | null;
|
|
7434
|
+
private inputOptions;
|
|
7435
|
+
private lazyLoad;
|
|
7436
|
+
private connecting;
|
|
7437
|
+
constructor(input?: RedisDataSourceInput);
|
|
7309
7438
|
/**
|
|
7310
7439
|
* @description Returns the raw ioredis connection
|
|
7311
7440
|
* @returns {Redis}
|
|
7312
7441
|
*/
|
|
7313
7442
|
get ioredis(): Redis;
|
|
7314
7443
|
/**
|
|
7315
|
-
* @description
|
|
7316
|
-
* @description The User input connection details will always come first
|
|
7317
|
-
* @description This is intended as a singleton connection to the redis database, if you need multiple connections, use the getConnection method
|
|
7318
|
-
*/
|
|
7319
|
-
static connect(input?: RedisOptions): Promise<void>;
|
|
7320
|
-
/**
|
|
7321
|
-
* @description Establishes a connection to the redis database and returns the connection
|
|
7322
|
-
* @param input
|
|
7323
|
-
* @returns
|
|
7324
|
-
*/
|
|
7325
|
-
static getConnection(input?: RedisOptions): Promise<RedisDataSource>;
|
|
7326
|
-
/**
|
|
7327
|
-
* @description Sets a key-value pair in the redis database
|
|
7328
|
-
* @param {string} key - The key
|
|
7329
|
-
* @param {string} value - The value
|
|
7330
|
-
* @param {number} expirationTime - The expiration time in milliseconds
|
|
7331
|
-
*/
|
|
7332
|
-
static set(key: string, value: RedisStorable, expirationTime?: number): Promise<void>;
|
|
7333
|
-
/**
|
|
7334
|
-
* @description Gets the value of a key in the redis database
|
|
7335
|
-
* @param {string} key - The key
|
|
7336
|
-
* @returns {Promise<string>}
|
|
7337
|
-
*/
|
|
7338
|
-
static get<T = RedisFetchable>(key: string): Promise<T | null>;
|
|
7339
|
-
/**
|
|
7340
|
-
* @description Gets the value of a key in the redis database as a buffer
|
|
7341
|
-
*/
|
|
7342
|
-
static getBuffer(key: string): Promise<Buffer | null>;
|
|
7343
|
-
/**
|
|
7344
|
-
* @description Gets the value of a key in the redis database and deletes the key
|
|
7345
|
-
* @param {string} key - The key
|
|
7346
|
-
* @returns {Promise
|
|
7347
|
-
* <T | null>}
|
|
7444
|
+
* @description Establishes a connection to the redis database. The ioredis driver is dynamically imported.
|
|
7348
7445
|
*/
|
|
7349
|
-
|
|
7350
|
-
/**
|
|
7351
|
-
* @description Deletes a key from the redis database
|
|
7352
|
-
* @param {string} key - The key
|
|
7353
|
-
* @returns {Promise<void>}
|
|
7354
|
-
*/
|
|
7355
|
-
static delete(key: string): Promise<void>;
|
|
7356
|
-
/**
|
|
7357
|
-
* @description Flushes all the data in the redis database
|
|
7358
|
-
* @returns {Promise<void>}
|
|
7359
|
-
*/
|
|
7360
|
-
static flushAll(): Promise<void>;
|
|
7446
|
+
connect(): Promise<void>;
|
|
7361
7447
|
/**
|
|
7362
|
-
* @description
|
|
7363
|
-
* @returns {Promise<void>}
|
|
7448
|
+
* @description Ensures the connection is established. If lazyLoad is true and not connected, connects automatically.
|
|
7364
7449
|
*/
|
|
7365
|
-
|
|
7450
|
+
private ensureConnected;
|
|
7366
7451
|
/**
|
|
7367
7452
|
* @description Sets a key-value pair in the redis database
|
|
7368
7453
|
* @param {string} key - The key
|
|
@@ -7404,46 +7489,6 @@ declare class RedisDataSource {
|
|
|
7404
7489
|
* @returns {Promise<void>}
|
|
7405
7490
|
*/
|
|
7406
7491
|
disconnect(forceError?: boolean): Promise<void>;
|
|
7407
|
-
/**
|
|
7408
|
-
* @description Adds one or more values to the beginning of a list
|
|
7409
|
-
* @param {string} key - The key of the list
|
|
7410
|
-
* @param {RedisStorable[]} values - The values to add
|
|
7411
|
-
* @returns {Promise<number>} - The length of the list after the push operation
|
|
7412
|
-
*/
|
|
7413
|
-
static lpush(key: string, ...values: RedisStorable[]): Promise<number>;
|
|
7414
|
-
/**
|
|
7415
|
-
* @description Adds one or more values to the end of a list
|
|
7416
|
-
* @param {string} key - The key of the list
|
|
7417
|
-
* @param {RedisStorable[]} values - The values to add
|
|
7418
|
-
* @returns {Promise<number>} - The length of the list after the push operation
|
|
7419
|
-
*/
|
|
7420
|
-
static rpush(key: string, ...values: RedisStorable[]): Promise<number>;
|
|
7421
|
-
/**
|
|
7422
|
-
* @description Removes and returns the first element of a list
|
|
7423
|
-
* @param {string} key - The key of the list
|
|
7424
|
-
* @returns {Promise<T | null>} - The popped value
|
|
7425
|
-
*/
|
|
7426
|
-
static lpop<T = RedisFetchable>(key: string): Promise<T | null>;
|
|
7427
|
-
/**
|
|
7428
|
-
* @description Removes and returns the last element of a list
|
|
7429
|
-
* @param {string} key - The key of the list
|
|
7430
|
-
* @returns {Promise<T | null>} - The popped value
|
|
7431
|
-
*/
|
|
7432
|
-
static rpop<T = RedisFetchable>(key: string): Promise<T | null>;
|
|
7433
|
-
/**
|
|
7434
|
-
* @description Gets a range of elements from a list
|
|
7435
|
-
* @param {string} key - The key of the list
|
|
7436
|
-
* @param {number} start - The starting index
|
|
7437
|
-
* @param {number} stop - The stopping index
|
|
7438
|
-
* @returns {Promise<T[]>} - Array of elements in the specified range
|
|
7439
|
-
*/
|
|
7440
|
-
static lrange<T = RedisFetchable>(key: string, start: number, stop: number): Promise<T[]>;
|
|
7441
|
-
/**
|
|
7442
|
-
* @description Gets the length of a list
|
|
7443
|
-
* @param {string} key - The key of the list
|
|
7444
|
-
* @returns {Promise<number>} - The length of the list
|
|
7445
|
-
*/
|
|
7446
|
-
static llen(key: string): Promise<number>;
|
|
7447
7492
|
/**
|
|
7448
7493
|
* @description Adds one or more values to the beginning of a list
|
|
7449
7494
|
* @param {string} key - The key of the list
|
|
@@ -7484,67 +7529,6 @@ declare class RedisDataSource {
|
|
|
7484
7529
|
* @returns {Promise<number>} - The length of the list
|
|
7485
7530
|
*/
|
|
7486
7531
|
llen(key: string): Promise<number>;
|
|
7487
|
-
/**
|
|
7488
|
-
* @description Sets field in the hash stored at key to value
|
|
7489
|
-
* @param {string} key - The key of the hash
|
|
7490
|
-
* @param {string} field - The field to set
|
|
7491
|
-
* @param {RedisStorable} value - The value to set
|
|
7492
|
-
* @returns {Promise<number>} - 1 if field is a new field and value was set, 0 if field already exists and the value was updated
|
|
7493
|
-
*/
|
|
7494
|
-
static hset(key: string, field: string, value: RedisStorable): Promise<number>;
|
|
7495
|
-
/**
|
|
7496
|
-
* @description Sets multiple fields in the hash stored at key to their respective values
|
|
7497
|
-
* @param {string} key - The key of the hash
|
|
7498
|
-
* @param {Record<string, RedisStorable>} hash - Object containing field-value pairs
|
|
7499
|
-
* @returns {Promise<string>} - "OK" if successful
|
|
7500
|
-
*/
|
|
7501
|
-
static hmset(key: string, hash: Record<string, RedisStorable>): Promise<string>;
|
|
7502
|
-
/**
|
|
7503
|
-
* @description Gets the value of a field in a hash
|
|
7504
|
-
* @param {string} key - The key of the hash
|
|
7505
|
-
* @param {string} field - The field to get
|
|
7506
|
-
* @returns {Promise<T | null>} - The value of the field
|
|
7507
|
-
*/
|
|
7508
|
-
static hget<T = RedisFetchable>(key: string, field: string): Promise<T | null>;
|
|
7509
|
-
/**
|
|
7510
|
-
* @description Gets all the fields and values in a hash
|
|
7511
|
-
* @param {string} key - The key of the hash
|
|
7512
|
-
* @returns {Promise<Record<string, T>>} - Object containing field-value pairs
|
|
7513
|
-
*/
|
|
7514
|
-
static hgetall<T = RedisFetchable>(key: string): Promise<Record<string, T>>;
|
|
7515
|
-
/**
|
|
7516
|
-
* @description Gets values for multiple fields in a hash
|
|
7517
|
-
* @param {string} key - The key of the hash
|
|
7518
|
-
* @param {string[]} fields - The fields to get
|
|
7519
|
-
* @returns {Promise<Array<T | null>>} - Array of values
|
|
7520
|
-
*/
|
|
7521
|
-
static hmget<T = RedisFetchable>(key: string, ...fields: string[]): Promise<Array<T | null>>;
|
|
7522
|
-
/**
|
|
7523
|
-
* @description Deletes one or more fields from a hash
|
|
7524
|
-
* @param {string} key - The key of the hash
|
|
7525
|
-
* @param {string[]} fields - The fields to delete
|
|
7526
|
-
* @returns {Promise<number>} - The number of fields that were removed
|
|
7527
|
-
*/
|
|
7528
|
-
static hdel(key: string, ...fields: string[]): Promise<number>;
|
|
7529
|
-
/**
|
|
7530
|
-
* @description Checks if a field exists in a hash
|
|
7531
|
-
* @param {string} key - The key of the hash
|
|
7532
|
-
* @param {string} field - The field to check
|
|
7533
|
-
* @returns {Promise<number>} - 1 if the field exists, 0 if not
|
|
7534
|
-
*/
|
|
7535
|
-
static hexists(key: string, field: string): Promise<number>;
|
|
7536
|
-
/**
|
|
7537
|
-
* @description Gets all the fields in a hash
|
|
7538
|
-
* @param {string} key - The key of the hash
|
|
7539
|
-
* @returns {Promise<string[]>} - Array of field names
|
|
7540
|
-
*/
|
|
7541
|
-
static hkeys(key: string): Promise<string[]>;
|
|
7542
|
-
/**
|
|
7543
|
-
* @description Gets the number of fields in a hash
|
|
7544
|
-
* @param {string} key - The key of the hash
|
|
7545
|
-
* @returns {Promise<number>} - The number of fields
|
|
7546
|
-
*/
|
|
7547
|
-
static hlen(key: string): Promise<number>;
|
|
7548
7532
|
/**
|
|
7549
7533
|
* @description Sets field in the hash stored at key to value
|
|
7550
7534
|
* @param {string} key - The key of the hash
|
|
@@ -7606,57 +7590,6 @@ declare class RedisDataSource {
|
|
|
7606
7590
|
* @returns {Promise<number>} - The number of fields
|
|
7607
7591
|
*/
|
|
7608
7592
|
hlen(key: string): Promise<number>;
|
|
7609
|
-
/**
|
|
7610
|
-
* @description Adds one or more members to a set
|
|
7611
|
-
* @param {string} key - The key of the set
|
|
7612
|
-
* @param {RedisStorable[]} members - The members to add
|
|
7613
|
-
* @returns {Promise<number>} - The number of elements added to the set
|
|
7614
|
-
*/
|
|
7615
|
-
static sadd(key: string, ...members: RedisStorable[]): Promise<number>;
|
|
7616
|
-
/**
|
|
7617
|
-
* @description Gets all members of a set
|
|
7618
|
-
* @param {string} key - The key of the set
|
|
7619
|
-
* @returns {Promise<T[]>} - Array of set members
|
|
7620
|
-
*/
|
|
7621
|
-
static smembers<T = RedisFetchable>(key: string): Promise<T[]>;
|
|
7622
|
-
/**
|
|
7623
|
-
* @description Removes one or more members from a set
|
|
7624
|
-
* @param {string} key - The key of the set
|
|
7625
|
-
* @param {RedisStorable[]} members - The members to remove
|
|
7626
|
-
* @returns {Promise<number>} - The number of members that were removed
|
|
7627
|
-
*/
|
|
7628
|
-
static srem(key: string, ...members: RedisStorable[]): Promise<number>;
|
|
7629
|
-
/**
|
|
7630
|
-
* @description Determines whether a member belongs to a set
|
|
7631
|
-
* @param {string} key - The key of the set
|
|
7632
|
-
* @param {RedisStorable} member - The member to check
|
|
7633
|
-
* @returns {Promise<number>} - 1 if the member exists in the set, 0 if not
|
|
7634
|
-
*/
|
|
7635
|
-
static sismember(key: string, member: RedisStorable): Promise<number>;
|
|
7636
|
-
/**
|
|
7637
|
-
* @description Gets the number of members in a set
|
|
7638
|
-
* @param {string} key - The key of the set
|
|
7639
|
-
* @returns {Promise<number>} - The number of members in the set
|
|
7640
|
-
*/
|
|
7641
|
-
static scard(key: string): Promise<number>;
|
|
7642
|
-
/**
|
|
7643
|
-
* @description Returns the intersection of multiple sets
|
|
7644
|
-
* @param {string[]} keys - The keys of the sets to intersect
|
|
7645
|
-
* @returns {Promise<T[]>} - Array of members in the intersection
|
|
7646
|
-
*/
|
|
7647
|
-
static sinter<T = RedisFetchable>(...keys: string[]): Promise<T[]>;
|
|
7648
|
-
/**
|
|
7649
|
-
* @description Returns the union of multiple sets
|
|
7650
|
-
* @param {string[]} keys - The keys of the sets to union
|
|
7651
|
-
* @returns {Promise<T[]>} - Array of members in the union
|
|
7652
|
-
*/
|
|
7653
|
-
static sunion<T = RedisFetchable>(...keys: string[]): Promise<T[]>;
|
|
7654
|
-
/**
|
|
7655
|
-
* @description Returns the difference between the first set and all successive sets
|
|
7656
|
-
* @param {string[]} keys - The keys of the sets to diff
|
|
7657
|
-
* @returns {Promise<T[]>} - Array of members in the difference
|
|
7658
|
-
*/
|
|
7659
|
-
static sdiff<T = RedisFetchable>(...keys: string[]): Promise<T[]>;
|
|
7660
7593
|
/**
|
|
7661
7594
|
* @description Adds one or more members to a set
|
|
7662
7595
|
* @param {string} key - The key of the set
|
|
@@ -7708,59 +7641,6 @@ declare class RedisDataSource {
|
|
|
7708
7641
|
* @returns {Promise<T[]>} - Array of members in the difference
|
|
7709
7642
|
*/
|
|
7710
7643
|
sdiff<T = RedisFetchable>(...keys: string[]): Promise<T[]>;
|
|
7711
|
-
/**
|
|
7712
|
-
* @description Adds a member to a sorted set, or updates the score of an existing member
|
|
7713
|
-
* @param {string} key - The key of the sorted set
|
|
7714
|
-
* @param {number} score - The score associated with the member
|
|
7715
|
-
* @param {RedisStorable} member - The member to add or update
|
|
7716
|
-
* @returns {Promise<number>} - The number of new members added to the sorted set
|
|
7717
|
-
*/
|
|
7718
|
-
static zadd(key: string, score: number, member: RedisStorable): Promise<number>;
|
|
7719
|
-
static zadd(key: string, scoreMembers: Array<[number, RedisStorable]>): Promise<number>;
|
|
7720
|
-
/**
|
|
7721
|
-
* @description Gets a range of members from a sorted set, ordered by score
|
|
7722
|
-
* @param {string} key - The key of the sorted set
|
|
7723
|
-
* @param {number} start - The starting index
|
|
7724
|
-
* @param {number} stop - The stopping index
|
|
7725
|
-
* @param {boolean} withScores - Whether to return the scores along with the members
|
|
7726
|
-
* @returns {Promise<T[] | Array<{value: T, score: number}>>} - Array of members or [member, score] pairs
|
|
7727
|
-
*/
|
|
7728
|
-
static zrange<T = RedisFetchable>(key: string, start: number, stop: number, withScores?: boolean): Promise<T[] | Array<{
|
|
7729
|
-
value: T;
|
|
7730
|
-
score: number;
|
|
7731
|
-
}>>;
|
|
7732
|
-
/**
|
|
7733
|
-
* @description Gets a range of members from a sorted set, ordered by score in descending order
|
|
7734
|
-
* @param {string} key - The key of the sorted set
|
|
7735
|
-
* @param {number} start - The starting index
|
|
7736
|
-
* @param {number} stop - The stopping index
|
|
7737
|
-
* @param {boolean} withScores - Whether to return the scores along with the members
|
|
7738
|
-
* @returns {Promise<T[] | Array<{value: T, score: number}>>} - Array of members or [member, score] pairs
|
|
7739
|
-
*/
|
|
7740
|
-
static zrevrange<T = RedisFetchable>(key: string, start: number, stop: number, withScores?: boolean): Promise<T[] | Array<{
|
|
7741
|
-
value: T;
|
|
7742
|
-
score: number;
|
|
7743
|
-
}>>;
|
|
7744
|
-
/**
|
|
7745
|
-
* @description Removes one or more members from a sorted set
|
|
7746
|
-
* @param {string} key - The key of the sorted set
|
|
7747
|
-
* @param {RedisStorable[]} members - The members to remove
|
|
7748
|
-
* @returns {Promise<number>} - The number of members removed
|
|
7749
|
-
*/
|
|
7750
|
-
static zrem(key: string, ...members: RedisStorable[]): Promise<number>;
|
|
7751
|
-
/**
|
|
7752
|
-
* @description Gets the score of a member in a sorted set
|
|
7753
|
-
* @param {string} key - The key of the sorted set
|
|
7754
|
-
* @param {RedisStorable} member - The member to get the score of
|
|
7755
|
-
* @returns {Promise<number | null>} - The score of the member, or null if the member does not exist
|
|
7756
|
-
*/
|
|
7757
|
-
static zscore(key: string, member: RedisStorable): Promise<number | null>;
|
|
7758
|
-
/**
|
|
7759
|
-
* @description Gets the number of members in a sorted set
|
|
7760
|
-
* @param {string} key - The key of the sorted set
|
|
7761
|
-
* @returns {Promise<number>} - The number of members in the sorted set
|
|
7762
|
-
*/
|
|
7763
|
-
static zcard(key: string): Promise<number>;
|
|
7764
7644
|
/**
|
|
7765
7645
|
* @description Adds a member to a sorted set, or updates the score of an existing member
|
|
7766
7646
|
* @param {string} key - The key of the sorted set
|
|
@@ -7814,39 +7694,6 @@ declare class RedisDataSource {
|
|
|
7814
7694
|
* @returns {Promise<number>} - The number of members in the sorted set
|
|
7815
7695
|
*/
|
|
7816
7696
|
zcard(key: string): Promise<number>;
|
|
7817
|
-
/**
|
|
7818
|
-
* @description Subscribes to one or more channels
|
|
7819
|
-
* @param {string[]} channels - The channels to subscribe to
|
|
7820
|
-
* @param {RedisMessageHandler} handler - The function to call when a message is received
|
|
7821
|
-
* @returns {Promise<void>}
|
|
7822
|
-
*/
|
|
7823
|
-
static subscribe(channels: string[], handler: RedisMessageHandler): Promise<void>;
|
|
7824
|
-
/**
|
|
7825
|
-
* @description Unsubscribes from one or more channels
|
|
7826
|
-
* @param {string[]} channels - The channels to unsubscribe from
|
|
7827
|
-
* @returns {Promise<void>}
|
|
7828
|
-
*/
|
|
7829
|
-
static unsubscribe(...channels: string[]): Promise<void>;
|
|
7830
|
-
/**
|
|
7831
|
-
* @description Publishes a message to a channel
|
|
7832
|
-
* @param {string} channel - The channel to publish to
|
|
7833
|
-
* @param {RedisStorable} message - The message to publish
|
|
7834
|
-
* @returns {Promise<number>} - The number of clients that received the message
|
|
7835
|
-
*/
|
|
7836
|
-
static publish(channel: string, message: RedisStorable): Promise<number>;
|
|
7837
|
-
/**
|
|
7838
|
-
* @description Pattern subscribe to channels
|
|
7839
|
-
* @param {string[]} patterns - The patterns to subscribe to
|
|
7840
|
-
* @param {RedisMessageHandler} handler - The function to call when a message is received
|
|
7841
|
-
* @returns {Promise<void>}
|
|
7842
|
-
*/
|
|
7843
|
-
static psubscribe(patterns: string[], handler: RedisMessageHandler): Promise<void>;
|
|
7844
|
-
/**
|
|
7845
|
-
* @description Pattern unsubscribe from channels
|
|
7846
|
-
* @param {string[]} patterns - The patterns to unsubscribe from
|
|
7847
|
-
* @returns {Promise<void>}
|
|
7848
|
-
*/
|
|
7849
|
-
static punsubscribe(...patterns: string[]): Promise<void>;
|
|
7850
7697
|
/**
|
|
7851
7698
|
* @description Subscribes to one or more channels
|
|
7852
7699
|
* @param {string[]} channels - The channels to subscribe to
|
|
@@ -7880,70 +7727,6 @@ declare class RedisDataSource {
|
|
|
7880
7727
|
* @returns {Promise<void>}
|
|
7881
7728
|
*/
|
|
7882
7729
|
punsubscribe(...patterns: string[]): Promise<void>;
|
|
7883
|
-
/**
|
|
7884
|
-
* @description Checks if a key exists
|
|
7885
|
-
* @param {string} key - The key to check
|
|
7886
|
-
* @returns {Promise<number>} - 1 if the key exists, 0 if not
|
|
7887
|
-
*/
|
|
7888
|
-
static exists(key: string): Promise<number>;
|
|
7889
|
-
/**
|
|
7890
|
-
* @description Sets the expiration time of a key
|
|
7891
|
-
* @param {string} key - The key to set the expiration for
|
|
7892
|
-
* @param {number} seconds - The expiration time in seconds
|
|
7893
|
-
* @returns {Promise<number>} - 1 if the timeout was set, 0 if not
|
|
7894
|
-
*/
|
|
7895
|
-
static expire(key: string, seconds: number): Promise<number>;
|
|
7896
|
-
/**
|
|
7897
|
-
* @description Sets the expiration time of a key using a UNIX timestamp
|
|
7898
|
-
* @param {string} key - The key to set the expiration for
|
|
7899
|
-
* @param {number} timestamp - UNIX timestamp in seconds
|
|
7900
|
-
* @returns {Promise<number>} - 1 if the timeout was set, 0 if not
|
|
7901
|
-
*/
|
|
7902
|
-
static expireat(key: string, timestamp: number): Promise<number>;
|
|
7903
|
-
/**
|
|
7904
|
-
* @description Sets the expiration time of a key in milliseconds
|
|
7905
|
-
* @param {string} key - The key to set the expiration for
|
|
7906
|
-
* @param {number} milliseconds - The expiration time in milliseconds
|
|
7907
|
-
* @returns {Promise<number>} - 1 if the timeout was set, 0 if not
|
|
7908
|
-
*/
|
|
7909
|
-
static pexpire(key: string, milliseconds: number): Promise<number>;
|
|
7910
|
-
/**
|
|
7911
|
-
* @description Gets the remaining time to live of a key in seconds
|
|
7912
|
-
* @param {string} key - The key to get the TTL for
|
|
7913
|
-
* @returns {Promise<number>} - TTL in seconds, -1 if no expiry, -2 if key doesn't exist
|
|
7914
|
-
*/
|
|
7915
|
-
static ttl(key: string): Promise<number>;
|
|
7916
|
-
/**
|
|
7917
|
-
* @description Gets the remaining time to live of a key in milliseconds
|
|
7918
|
-
* @param {string} key - The key to get the TTL for
|
|
7919
|
-
* @returns {Promise<number>} - TTL in milliseconds, -1 if no expiry, -2 if key doesn't exist
|
|
7920
|
-
*/
|
|
7921
|
-
static pttl(key: string): Promise<number>;
|
|
7922
|
-
/**
|
|
7923
|
-
* @description Removes the expiration time from a key
|
|
7924
|
-
* @param {string} key - The key to persist
|
|
7925
|
-
* @returns {Promise<number>} - 1 if the timeout was removed, 0 if not
|
|
7926
|
-
*/
|
|
7927
|
-
static persist(key: string): Promise<number>;
|
|
7928
|
-
/**
|
|
7929
|
-
* @description Gets all keys matching a pattern
|
|
7930
|
-
* @param {string} pattern - The pattern to match
|
|
7931
|
-
* @returns {Promise<string[]>} - Array of matching keys
|
|
7932
|
-
*/
|
|
7933
|
-
static keys(pattern: string): Promise<string[]>;
|
|
7934
|
-
/**
|
|
7935
|
-
* @description Renames a key
|
|
7936
|
-
* @param {string} key - The key to rename
|
|
7937
|
-
* @param {string} newKey - The new name for the key
|
|
7938
|
-
* @returns {Promise<string>} - "OK" if successful
|
|
7939
|
-
*/
|
|
7940
|
-
static rename(key: string, newKey: string): Promise<string>;
|
|
7941
|
-
/**
|
|
7942
|
-
* @description Returns the type of value stored at a key
|
|
7943
|
-
* @param {string} key - The key to check
|
|
7944
|
-
* @returns {Promise<string>} - Type of key (string, list, set, zset, hash, or none if key doesn't exist)
|
|
7945
|
-
*/
|
|
7946
|
-
static type(key: string): Promise<string>;
|
|
7947
7730
|
/**
|
|
7948
7731
|
* @description Checks if a key exists
|
|
7949
7732
|
* @param {string} key - The key to check
|
|
@@ -8299,4 +8082,4 @@ declare const generateOpenApiModelWithMetadata: <T extends new () => Model>(mode
|
|
|
8299
8082
|
$id?: string;
|
|
8300
8083
|
}>;
|
|
8301
8084
|
|
|
8302
|
-
export { type AdminJsActionOptions, type AdminJsAssets, type AdminJsBranding, type AdminJsInstance, type AdminJsLocale, type AdminJsOptions, type AdminJsPage, type AdminJsPropertyOptions, type AdminJsResourceOptions, type AdminJsSettings, type AnyModelConstructor, type BaseModelMethodOptions, BaseSeeder, type BuildSelectType, type BuildSingleSelectType, type CacheAdapter, type CacheKeys, ClientMigrator, type ColCharOptions, type ColJsonbOptions, type ColMediumIntOptions, type ColSmallIntOptions, type ColTinyIntOptions, type ColVarbinaryOptions, Collection, type CollectionDefinition, type ColumnDef, type CommonDataSourceInput, type ComposeBuildSelect, type ComposeSelect, type ConnectionPolicies, type CreateSchemaResult, type CustomLogger, type DataSourceInput, type DataSourceType, type DateAutoHook, type DefinedCollection, type DefinedModel, type DefinedView, type ExcludeMethods, type ExtractColumnName, type ExtractSourceColumn, type FetchHooks, type FindReturnType, type GetColumnType, type GetConnectionReturnType, HysteriaError, InMemoryAdapter, type InferPK, type LoadOptions, type LoggerConfig, type ManyOptions, Migration, type MigrationConfig, type MigrationConfigBase, type ModelColumns, type ModelDataProperties, type ModelInstanceType, type ModelKey, ModelQueryBuilder, type ModelQueryResult, type ModelRelation, type ModelSelectTuple, type ModelSelectableInput, type ModelWithoutRelations, type ModelsProxy, MongoDataSource, type MongoDataSourceInput$1 as MongoDataSourceInput, type MssqlConnectionInstance, type MssqlDataSourceInput, type MssqlPoolInstance, type MutationReturningResult, type MysqlConnectionInstance, type MysqlSqlDataSourceInput, type NotNullableMysqlSqlDataSourceInput, type NotNullableOracleDBDataSourceInput, type NotNullableOracleMssqlDataSourceInput, type NotNullablePostgresSqlDataSourceInput, type NotNullableSqliteDataSourceInput, type NullableColumn, type NumberModelKey, type OneOptions, type OracleDBDataSourceInput, type OracleDBPoolInstance, type PgPoolClientInstance, type PostgresSqlDataSourceInput, type PrimaryColumnDef, type PropNamespace, type PropertyDef, QueryBuilder, type RawModelKey, type RawModelOptions, RawNode, type RawQueryOptions, RedisCacheAdapter, type RedisFetchable, type RedisStorable, type RelatedInstance, type RelationDef, type RelationDefinitions, type RelationHelpers, type RelationLoadStrategy, type RelationQueryBuilderType, type ReplicationType, type ReturningColumns, type ReturningKey, type ReturningParam, type ReturningResult, type ReturningResultMany, type ReturningSupported, Schema, SchemaBuilder, type SchemaLookup, type SchemaRelDef, type SeederConfig, type SelectBrand, type SelectableColumn$1 as SelectableColumn, type SelectedModel, type SlaveAlgorithm, type SlaveContext, type SqlCloneOptions, SqlDataSource, type SqlDataSourceInput, type SqlDataSourceModel, type SqlDataSourceType, type SqlDriverSpecificOptions, type SqlPoolType, type Sqlite3ConnectionOptions, type SqliteConnectionInstance, type SqliteDataSourceInput, type StartTransactionOptions, type StripTablePrefix, type SubQueryable, type TableFormat, Transaction, type TransactionExecutionOptions, type TypedDefault, type TypedPrepare, type TypedSerialize, type UseCacheReturnType, type UseConnectionInput, type ViewDefinition, WriteOperation, type WriteReturnType, col, createSchema, defineCollection, defineMigrator, defineModel, defineModelFactory, defineRelations, defineView, generateOpenApiModel, generateOpenApiModelSchema, generateOpenApiModelWithMetadata, type getPoolReturnType, HysteriaLogger as logger, prop, RedisDataSource as redis, withPerformance };
|
|
8085
|
+
export { type AdminJsActionOptions, type AdminJsAssets, type AdminJsBranding, type AdminJsInstance, type AdminJsLocale, type AdminJsOptions, type AdminJsPage, type AdminJsPropertyOptions, type AdminJsResourceOptions, type AdminJsSettings, type AnyModelConstructor, type BaseModelMethodOptions, BaseSeeder, type BuildSelectType, type BuildSingleSelectType, type CacheAdapter, type CacheKeys, ClientMigrator, type ColCharOptions, type ColJsonbOptions, type ColMediumIntOptions, type ColSmallIntOptions, type ColTinyIntOptions, type ColVarbinaryOptions, Collection, type CollectionDefinition, type ColumnDef, type CommonDataSourceInput, type ComposeBuildSelect, type ComposeSelect, type ConnectionPolicies, type CreateSchemaResult, type CustomLogger, type DataSourceInput, type DataSourceType, type DateAutoHook, type DefinedCollection, type DefinedModel, type DefinedView, type ExcludeMethods, type ExtractColumnName, type ExtractSourceColumn, type FetchHooks, type FindReturnType, type GetColumnType, type GetConnectionReturnType, HysteriaError, InMemoryAdapter, type InferPK, type JsonPathInput, type JsonPaths, type LoadOptions, type LoggerConfig, type ManyOptions, Migration, type MigrationConfig, type MigrationConfigBase, type ModelColumns, type ModelDataProperties, type ModelInstanceType, type ModelKey, ModelQueryBuilder, type ModelQueryResult, type ModelRelation, type ModelSelectTuple, type ModelSelectableInput, type ModelWithoutRelations, type ModelsProxy, MongoDataSource, type MongoDataSourceInput$1 as MongoDataSourceInput, type MssqlConnectionInstance, type MssqlDataSourceInput, type MssqlPoolInstance, type MutationReturningResult, type MysqlConnectionInstance, type MysqlSqlDataSourceInput, type NotNullableMysqlSqlDataSourceInput, type NotNullableOracleDBDataSourceInput, type NotNullableOracleMssqlDataSourceInput, type NotNullablePostgresSqlDataSourceInput, type NotNullableSqliteDataSourceInput, type NullableColumn, type NumberModelKey, type OneOptions, type OracleDBDataSourceInput, type OracleDBPoolInstance, type PgPoolClientInstance, type PostgresSqlDataSourceInput, type PrimaryColumnDef, type PropNamespace, type PropertyDef, QueryBuilder, type RawModelKey, type RawModelOptions, RawNode, type RawQueryOptions, RedisCacheAdapter, type RedisFetchable, type RedisStorable, type RelatedInstance, type RelationDef, type RelationDefinitions, type RelationHelpers, type RelationLoadStrategy, type RelationQueryBuilderType, type ReplicationType, type ResolveColumnType, type ResolveJsonPathType, type ReturningColumns, type ReturningKey, type ReturningParam, type ReturningResult, type ReturningResultMany, type ReturningSupported, Schema, SchemaBuilder, type SchemaLookup, type SchemaRelDef, type SeederConfig, type SelectBrand, type SelectableColumn$1 as SelectableColumn, type SelectedModel, type SlaveAlgorithm, type SlaveContext, type SqlCloneOptions, SqlDataSource, type SqlDataSourceInput, type SqlDataSourceModel, type SqlDataSourceType, type SqlDriverSpecificOptions, type SqlPoolType, type Sqlite3ConnectionOptions, type SqliteConnectionInstance, type SqliteDataSourceInput, type StartTransactionOptions, type StripTablePrefix, type SubQueryable, type TableFormat, Transaction, type TransactionExecutionOptions, type TypedDefault, type TypedJsonPathInput, type TypedPrepare, type TypedSerialize, type UseCacheReturnType, type UseConnectionInput, type ViewDefinition, WriteOperation, type WriteReturnType, col, createSchema, defineCollection, defineMigrator, defineModel, defineModelFactory, defineRelations, defineView, generateOpenApiModel, generateOpenApiModelSchema, generateOpenApiModelWithMetadata, type getPoolReturnType, HysteriaLogger as logger, prop, RedisDataSource as redis, withPerformance };
|