hysteria-orm 10.3.2 → 10.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cli.cjs +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 +10 -10
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +76 -9
- package/lib/index.d.ts +76 -9
- package/lib/index.js +10 -10
- package/lib/index.js.map +1 -1
- package/package.json +5 -5
package/lib/index.d.cts
CHANGED
|
@@ -1150,6 +1150,14 @@ type SqlDataSourceInputBase<T extends Record<string, SqlDataSourceModel> = {}, C
|
|
|
1150
1150
|
* @description Maps a SqlDataSourceType to its corresponding input interface
|
|
1151
1151
|
*/
|
|
1152
1152
|
type MapSqlDataSourceTypeToInput<D extends SqlDataSourceType> = D extends "mysql" | "mariadb" ? MysqlSqlDataSourceInput : D extends "postgres" | "cockroachdb" ? PostgresSqlDataSourceInput : D extends "sqlite" ? SqliteDataSourceInput : D extends "mssql" ? MssqlDataSourceInput : D extends "oracledb" ? OracleDBDataSourceInput : never;
|
|
1153
|
+
type SlaveContext = {
|
|
1154
|
+
type: SqlDataSourceType;
|
|
1155
|
+
host: string;
|
|
1156
|
+
port: number;
|
|
1157
|
+
username: string;
|
|
1158
|
+
password: string;
|
|
1159
|
+
database: string;
|
|
1160
|
+
};
|
|
1153
1161
|
/**
|
|
1154
1162
|
* @description The input type for the SqlDataSource constructor
|
|
1155
1163
|
* @description The connectionPolicies object is used to configure the connection policies for the sql data source
|
|
@@ -1168,6 +1176,10 @@ type SqlDataSourceInput<D extends SqlDataSourceType = SqlDataSourceType, T exten
|
|
|
1168
1176
|
* @description The replication configuration for the sql data source, it's used to configure the replication for the sql data source
|
|
1169
1177
|
*/
|
|
1170
1178
|
replication?: {
|
|
1179
|
+
/**
|
|
1180
|
+
* @description The function to call when a slave server fails, if not provided an error will be thrown
|
|
1181
|
+
*/
|
|
1182
|
+
onSlaveServerFailure?: (error: Error, context: SlaveContext) => void | Promise<void>;
|
|
1171
1183
|
/**
|
|
1172
1184
|
* @description The slaves data sources to use for the sql data source, slaves are automatically used for read operations unless specified otherwise
|
|
1173
1185
|
*/
|
|
@@ -1544,6 +1556,14 @@ declare class CreateTableBuilder extends BaseBuilder {
|
|
|
1544
1556
|
private sqlType;
|
|
1545
1557
|
constructor(sqlType: SqlDataSourceType, nodes: QueryNode[], tableName?: string, context?: "alter_table" | "create_table");
|
|
1546
1558
|
private build;
|
|
1559
|
+
/**
|
|
1560
|
+
* @description Adds a raw statement to an operation that will be executed as is
|
|
1561
|
+
* @example
|
|
1562
|
+
* ```ts
|
|
1563
|
+
* table.varchar("name").default(table.rawStatement("CURRENT_TIMESTAMP"));
|
|
1564
|
+
* ```
|
|
1565
|
+
*/
|
|
1566
|
+
rawStatement(value: string): RawNode;
|
|
1547
1567
|
/**
|
|
1548
1568
|
* Fixed-length character string
|
|
1549
1569
|
* @mysql Supported as CHAR(length)
|
|
@@ -1825,6 +1845,14 @@ declare class AlterTableBuilder extends BaseBuilder {
|
|
|
1825
1845
|
private table;
|
|
1826
1846
|
private sqlType;
|
|
1827
1847
|
constructor(table: string, nodes: QueryNode[], sqlType: SqlDataSourceType);
|
|
1848
|
+
/**
|
|
1849
|
+
* @description Adds a raw statement to an operation that will be executed as is
|
|
1850
|
+
* @example
|
|
1851
|
+
* ```ts
|
|
1852
|
+
* table.varchar("name").default(table.rawStatement("CURRENT_TIMESTAMP"));
|
|
1853
|
+
* ```
|
|
1854
|
+
*/
|
|
1855
|
+
rawStatement(value: string): RawNode;
|
|
1828
1856
|
/**
|
|
1829
1857
|
* @description Adds a column to the table
|
|
1830
1858
|
* @param cb is the callback that will be used to build the column
|
|
@@ -1918,6 +1946,17 @@ declare class Schema {
|
|
|
1918
1946
|
queryStatements: string[];
|
|
1919
1947
|
sqlType: SqlDataSourceType;
|
|
1920
1948
|
constructor(sqlType?: SqlDataSourceType);
|
|
1949
|
+
/**
|
|
1950
|
+
* @description Adds a raw statement to an operation that will be executed as is
|
|
1951
|
+
* @example
|
|
1952
|
+
* ```ts
|
|
1953
|
+
* schema.rawStatement("CURRENT_TIMESTAMP");
|
|
1954
|
+
* schema.alterTable("users", (table) => {
|
|
1955
|
+
* table.timestamp("created_at").default(this.schema.rawStatement("CURRENT_TIMESTAMP"));
|
|
1956
|
+
* });
|
|
1957
|
+
* ```
|
|
1958
|
+
*/
|
|
1959
|
+
rawStatement(value: string): RawNode;
|
|
1921
1960
|
/**
|
|
1922
1961
|
* @description Add raw query to the migration
|
|
1923
1962
|
*/
|
|
@@ -2037,7 +2076,7 @@ declare class DryQueryBuilder extends QueryBuilder {
|
|
|
2037
2076
|
* @warning This method does not run model or column hooks
|
|
2038
2077
|
* @returns The query builder
|
|
2039
2078
|
*/
|
|
2040
|
-
update(data: Record<string,
|
|
2079
|
+
update(data: Record<string, WriteQueryParam>): this;
|
|
2041
2080
|
/**
|
|
2042
2081
|
* @description Builds the delete query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
|
|
2043
2082
|
* @warning This method does not run model or column hooks
|
|
@@ -3107,6 +3146,7 @@ type UpsertOptionsRawBuilder = {
|
|
|
3107
3146
|
};
|
|
3108
3147
|
type DryQueryBuilderWithoutReadOperations = Omit<DryQueryBuilder, "many" | "one" | "oneOrFail" | "first" | "firstOrFail" | "paginate" | "paginateWithCursor" | "exists" | "pluck" | "increment" | "decrement" | "getSum" | "getAvg" | "getMin" | "getMax" | "getCount" | "stream" | "chunk" | "paginate" | "paginateWithCursor" | "exists">;
|
|
3109
3148
|
type DryModelQueryBuilderWithoutReadOperations<T extends Model, A extends Record<string, any> = {}, R extends Record<string, any> = {}> = Omit<DryModelQueryBuilder<T, A, R>, "many" | "one" | "oneOrFail" | "first" | "firstOrFail" | "paginate" | "paginateWithCursor" | "exists" | "pluck" | "upsert" | "upsertMany" | "increment" | "decrement" | "getSum" | "getAvg" | "getMin" | "getMax" | "getCount" | "stream" | "chunk" | "paginate" | "paginateWithCursor" | "exists">;
|
|
3149
|
+
type WriteQueryParam$1 = string | number | boolean | Date | RawNode | object | null | undefined;
|
|
3110
3150
|
|
|
3111
3151
|
declare class SqlModelManagerUtils<T extends Model> {
|
|
3112
3152
|
protected dbType: SqlDataSourceType;
|
|
@@ -3709,6 +3749,14 @@ declare class SqlDataSource<D extends SqlDataSourceType = SqlDataSourceType, T e
|
|
|
3709
3749
|
* @description Cached AdminJS instance
|
|
3710
3750
|
*/
|
|
3711
3751
|
private adminJsInstance?;
|
|
3752
|
+
/**
|
|
3753
|
+
* @description Callback to handle slave server failures
|
|
3754
|
+
*/
|
|
3755
|
+
private onSlaveServerFailure?;
|
|
3756
|
+
/**
|
|
3757
|
+
* @description Returns the configured slave failure callback
|
|
3758
|
+
*/
|
|
3759
|
+
getOnSlaveServerFailure(): ((error: Error, context: SlaveContext) => void | Promise<void>) | undefined;
|
|
3712
3760
|
/**
|
|
3713
3761
|
* @description Returns the primary instance of the SqlDataSource (set via connect with setPrimary: true)
|
|
3714
3762
|
* All models by default will use this instance to execute queries unless you pass a different connection/transaction in the query options
|
|
@@ -3938,10 +3986,16 @@ declare class SqlDataSource<D extends SqlDataSourceType = SqlDataSourceType, T e
|
|
|
3938
3986
|
*/
|
|
3939
3987
|
rawQuery<R = RawQueryResponseType<D>>(query: string, params?: any[], options?: RawQueryOptions): Promise<R>;
|
|
3940
3988
|
/**
|
|
3941
|
-
* @description Adds a raw statement to an operation
|
|
3989
|
+
* @description Adds a raw statement to an operation that will be executed as is
|
|
3942
3990
|
* @example
|
|
3943
3991
|
* ```ts
|
|
3944
|
-
* await
|
|
3992
|
+
* await sql.query("users").where("name", sql.rawStatement("LOWER(name)"));
|
|
3993
|
+
* await sql.query("users").update({
|
|
3994
|
+
* name: sql.rawStatement("LOWER(name)"),
|
|
3995
|
+
* });
|
|
3996
|
+
* await sql.query("users").insert({
|
|
3997
|
+
* name: sql.rawStatement("LOWER(name)"),
|
|
3998
|
+
* });
|
|
3945
3999
|
* ```
|
|
3946
4000
|
*/
|
|
3947
4001
|
rawStatement(value: string): RawNode;
|
|
@@ -3995,6 +4049,12 @@ declare class SqlDataSource<D extends SqlDataSourceType = SqlDataSourceType, T e
|
|
|
3995
4049
|
* @description Introspects table primary key from the database
|
|
3996
4050
|
*/
|
|
3997
4051
|
getPrimaryKeyInfo(table: string): Promise<TablePrimaryKeyInfo | undefined>;
|
|
4052
|
+
/**
|
|
4053
|
+
* @description Executes an operation on a slave, handling failures with the configured callback
|
|
4054
|
+
* @param operation The operation to execute on the slave
|
|
4055
|
+
* @returns The result of the operation, or falls back to master if slave fails
|
|
4056
|
+
*/
|
|
4057
|
+
private executeOnSlave;
|
|
3998
4058
|
/**
|
|
3999
4059
|
* @description Internal method to establish connection without setting as primary instance
|
|
4000
4060
|
* @description Used by connectToSecondarySource and useConnection
|
|
@@ -4328,18 +4388,18 @@ declare class QueryBuilder<T extends Model = any> extends JsonQueryBuilder<T> {
|
|
|
4328
4388
|
*/
|
|
4329
4389
|
withMaterialized(alias: string, cb: (qb: QueryBuilder<T>) => void): this;
|
|
4330
4390
|
/**
|
|
4331
|
-
* @description Insert record into a table
|
|
4391
|
+
* @description Insert record into a table, you can use raw statements in the data object for literal references to other columns
|
|
4332
4392
|
* @param returning - The columns to return from the query, only supported by postgres and cockroachdb - default is "*"
|
|
4333
4393
|
* @returns raw driver response
|
|
4334
4394
|
*/
|
|
4335
|
-
insert(data: Record<string,
|
|
4395
|
+
insert(data: Record<string, WriteQueryParam$1>, returning?: string[]): Promise<T>;
|
|
4336
4396
|
/**
|
|
4337
4397
|
* @description Insert multiple records into a table
|
|
4338
4398
|
* @param returning - The columns to return from the query, only supported by postgres and cockroachdb - default is "*"
|
|
4339
4399
|
* @returns raw driver response
|
|
4340
4400
|
* @oracledb may do multiple inserts with auto-generated identity columns
|
|
4341
4401
|
*/
|
|
4342
|
-
insertMany(data: Record<string,
|
|
4402
|
+
insertMany(data: Record<string, WriteQueryParam$1>[], returning?: string[]): Promise<T[]>;
|
|
4343
4403
|
/**
|
|
4344
4404
|
* @description Updates or creates a new record using upsert functionality
|
|
4345
4405
|
* @param data The data to insert or update
|
|
@@ -4361,10 +4421,10 @@ declare class QueryBuilder<T extends Model = any> extends JsonQueryBuilder<T> {
|
|
|
4361
4421
|
*/
|
|
4362
4422
|
private executeMssqlMergeRaw;
|
|
4363
4423
|
/**
|
|
4364
|
-
* @description Updates records from a table
|
|
4424
|
+
* @description Updates records from a table, you can use raw statements in the data object for literal references to other columns
|
|
4365
4425
|
* @returns the number of affected rows
|
|
4366
4426
|
*/
|
|
4367
|
-
update(data: Record<string,
|
|
4427
|
+
update(data: Record<string, WriteQueryParam$1>): Promise<number>;
|
|
4368
4428
|
/**
|
|
4369
4429
|
* @description Deletes all records from a table
|
|
4370
4430
|
* @warning This operation does not trigger any hook
|
|
@@ -4456,6 +4516,13 @@ declare class QueryBuilder<T extends Model = any> extends JsonQueryBuilder<T> {
|
|
|
4456
4516
|
*/
|
|
4457
4517
|
protected executePaginateQueries<M, C>(modelsQuery: () => Promise<M>, countQuery: () => Promise<C>): Promise<[M, C]>;
|
|
4458
4518
|
protected getSqlDataSource(mode: "read" | "write"): Promise<SqlDataSource>;
|
|
4519
|
+
/**
|
|
4520
|
+
* @description Executes SQL with slave failure handling
|
|
4521
|
+
* @param mode The operation mode (read or write)
|
|
4522
|
+
* @param operation The execSql operation to perform
|
|
4523
|
+
* @returns The result of the operation
|
|
4524
|
+
*/
|
|
4525
|
+
protected execSqlWithSlaveHandling<R>(mode: "read" | "write", operation: (dataSource: SqlDataSource) => Promise<R>): Promise<R>;
|
|
4459
4526
|
}
|
|
4460
4527
|
|
|
4461
4528
|
type UnionCallBack<T extends Model> = (queryBuilder: QueryBuilder<T>) => QueryBuilder<T>;
|
|
@@ -5934,4 +6001,4 @@ declare const generateOpenApiModelWithMetadata: <T extends new () => Model>(mode
|
|
|
5934
6001
|
$id?: string;
|
|
5935
6002
|
}>;
|
|
5936
6003
|
|
|
5937
|
-
export { type AdminJsActionOptions, type AdminJsAssets, type AdminJsBranding, type AdminJsInstance, type AdminJsLocale, type AdminJsOptions, type AdminJsPage, type AdminJsPropertyOptions, type AdminJsResourceOptions, type AdminJsSettings, type AnnotatedModel, type AsymmetricEncryptionOptions, AutogeneratedModel, type BaseModelMethodOptions, type BaseModelRelationType, type CacheAdapter, type CacheKeys, 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, DryModelQueryBuilder, DryQueryBuilder, type FetchHooks, type GetConnectionReturnType, HysteriaError, InMemoryAdapter, type IndexType, type LazyRelationType, type ManyOptions, type ManyToManyOptions, type ManyToManyStringOptions, Migration, Model, type ModelInstanceType, ModelQueryBuilder, type ModelWithoutRelations, MongoDataSource, type MongoDataSourceInput$1 as MongoDataSourceInput, type MssqlConnectionInstance, type MssqlDataSourceInput, type MssqlPoolInstance, type MysqlConnectionInstance, type MysqlSqlDataSourceInput, type NotNullableMysqlSqlDataSourceInput, type NotNullableOracleDBDataSourceInput, type NotNullableOracleMssqlDataSourceInput, type NotNullablePostgresSqlDataSourceInput, type NotNullableSqliteDataSourceInput, type NumberModelKey, type OneOptions, type OracleDBDataSourceInput, type OracleDBPoolInstance, type PgPoolClientInstance, type PostgresSqlDataSourceInput, QueryBuilder, type RawModelOptions, RawNode, type RawQueryOptions, RedisCacheAdapter, type RedisFetchable, type RedisStorable, type RelatedInstance, type RelationQueryBuilderType, type ReplicationType, type SlaveAlgorithm, type SqlCloneOptions, SqlDataSource, type SqlDataSourceInput, type SqlDataSourceModel, type SqlDataSourceType, type SqlDriverSpecificOptions, type SqlPoolType, type Sqlite3ConnectionOptions, type SqliteConnectionInstance, type SqliteDataSourceInput, type StartTransactionOptions, type SymmetricEncryptionOptions, type TableFormat, type ThroughModel, TimestampedModel, Transaction, type TransactionExecutionOptions, type UniqueType, type UseCacheReturnType, type UseConnectionInput, UserMixin, UuidModel, belongsTo, column, createModelFactory, defineMigrator, generateOpenApiModel, generateOpenApiModelSchema, generateOpenApiModelWithMetadata, getCollectionProperties, getIndexes, getModelColumns, type getPoolReturnType, getPrimaryKey, getRelations, getRelationsMetadata, getUniques, hasMany, hasOne, index, HysteriaLogger as logger, manyToMany, property, RedisDataSource as redis, unique, view, withPerformance };
|
|
6004
|
+
export { type AdminJsActionOptions, type AdminJsAssets, type AdminJsBranding, type AdminJsInstance, type AdminJsLocale, type AdminJsOptions, type AdminJsPage, type AdminJsPropertyOptions, type AdminJsResourceOptions, type AdminJsSettings, type AnnotatedModel, type AsymmetricEncryptionOptions, AutogeneratedModel, type BaseModelMethodOptions, type BaseModelRelationType, type CacheAdapter, type CacheKeys, 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, DryModelQueryBuilder, DryQueryBuilder, type FetchHooks, type GetConnectionReturnType, HysteriaError, InMemoryAdapter, type IndexType, type LazyRelationType, type ManyOptions, type ManyToManyOptions, type ManyToManyStringOptions, Migration, Model, type ModelInstanceType, ModelQueryBuilder, type ModelWithoutRelations, MongoDataSource, type MongoDataSourceInput$1 as MongoDataSourceInput, type MssqlConnectionInstance, type MssqlDataSourceInput, type MssqlPoolInstance, type MysqlConnectionInstance, type MysqlSqlDataSourceInput, type NotNullableMysqlSqlDataSourceInput, type NotNullableOracleDBDataSourceInput, type NotNullableOracleMssqlDataSourceInput, type NotNullablePostgresSqlDataSourceInput, type NotNullableSqliteDataSourceInput, type NumberModelKey, type OneOptions, type OracleDBDataSourceInput, type OracleDBPoolInstance, type PgPoolClientInstance, type PostgresSqlDataSourceInput, QueryBuilder, type RawModelOptions, RawNode, type RawQueryOptions, RedisCacheAdapter, type RedisFetchable, type RedisStorable, type RelatedInstance, type RelationQueryBuilderType, type ReplicationType, 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 SymmetricEncryptionOptions, type TableFormat, type ThroughModel, TimestampedModel, Transaction, type TransactionExecutionOptions, type UniqueType, type UseCacheReturnType, type UseConnectionInput, UserMixin, UuidModel, belongsTo, column, createModelFactory, defineMigrator, generateOpenApiModel, generateOpenApiModelSchema, generateOpenApiModelWithMetadata, getCollectionProperties, getIndexes, getModelColumns, type getPoolReturnType, getPrimaryKey, getRelations, getRelationsMetadata, getUniques, hasMany, hasOne, index, HysteriaLogger as logger, manyToMany, property, RedisDataSource as redis, unique, view, withPerformance };
|
package/lib/index.d.ts
CHANGED
|
@@ -1150,6 +1150,14 @@ type SqlDataSourceInputBase<T extends Record<string, SqlDataSourceModel> = {}, C
|
|
|
1150
1150
|
* @description Maps a SqlDataSourceType to its corresponding input interface
|
|
1151
1151
|
*/
|
|
1152
1152
|
type MapSqlDataSourceTypeToInput<D extends SqlDataSourceType> = D extends "mysql" | "mariadb" ? MysqlSqlDataSourceInput : D extends "postgres" | "cockroachdb" ? PostgresSqlDataSourceInput : D extends "sqlite" ? SqliteDataSourceInput : D extends "mssql" ? MssqlDataSourceInput : D extends "oracledb" ? OracleDBDataSourceInput : never;
|
|
1153
|
+
type SlaveContext = {
|
|
1154
|
+
type: SqlDataSourceType;
|
|
1155
|
+
host: string;
|
|
1156
|
+
port: number;
|
|
1157
|
+
username: string;
|
|
1158
|
+
password: string;
|
|
1159
|
+
database: string;
|
|
1160
|
+
};
|
|
1153
1161
|
/**
|
|
1154
1162
|
* @description The input type for the SqlDataSource constructor
|
|
1155
1163
|
* @description The connectionPolicies object is used to configure the connection policies for the sql data source
|
|
@@ -1168,6 +1176,10 @@ type SqlDataSourceInput<D extends SqlDataSourceType = SqlDataSourceType, T exten
|
|
|
1168
1176
|
* @description The replication configuration for the sql data source, it's used to configure the replication for the sql data source
|
|
1169
1177
|
*/
|
|
1170
1178
|
replication?: {
|
|
1179
|
+
/**
|
|
1180
|
+
* @description The function to call when a slave server fails, if not provided an error will be thrown
|
|
1181
|
+
*/
|
|
1182
|
+
onSlaveServerFailure?: (error: Error, context: SlaveContext) => void | Promise<void>;
|
|
1171
1183
|
/**
|
|
1172
1184
|
* @description The slaves data sources to use for the sql data source, slaves are automatically used for read operations unless specified otherwise
|
|
1173
1185
|
*/
|
|
@@ -1544,6 +1556,14 @@ declare class CreateTableBuilder extends BaseBuilder {
|
|
|
1544
1556
|
private sqlType;
|
|
1545
1557
|
constructor(sqlType: SqlDataSourceType, nodes: QueryNode[], tableName?: string, context?: "alter_table" | "create_table");
|
|
1546
1558
|
private build;
|
|
1559
|
+
/**
|
|
1560
|
+
* @description Adds a raw statement to an operation that will be executed as is
|
|
1561
|
+
* @example
|
|
1562
|
+
* ```ts
|
|
1563
|
+
* table.varchar("name").default(table.rawStatement("CURRENT_TIMESTAMP"));
|
|
1564
|
+
* ```
|
|
1565
|
+
*/
|
|
1566
|
+
rawStatement(value: string): RawNode;
|
|
1547
1567
|
/**
|
|
1548
1568
|
* Fixed-length character string
|
|
1549
1569
|
* @mysql Supported as CHAR(length)
|
|
@@ -1825,6 +1845,14 @@ declare class AlterTableBuilder extends BaseBuilder {
|
|
|
1825
1845
|
private table;
|
|
1826
1846
|
private sqlType;
|
|
1827
1847
|
constructor(table: string, nodes: QueryNode[], sqlType: SqlDataSourceType);
|
|
1848
|
+
/**
|
|
1849
|
+
* @description Adds a raw statement to an operation that will be executed as is
|
|
1850
|
+
* @example
|
|
1851
|
+
* ```ts
|
|
1852
|
+
* table.varchar("name").default(table.rawStatement("CURRENT_TIMESTAMP"));
|
|
1853
|
+
* ```
|
|
1854
|
+
*/
|
|
1855
|
+
rawStatement(value: string): RawNode;
|
|
1828
1856
|
/**
|
|
1829
1857
|
* @description Adds a column to the table
|
|
1830
1858
|
* @param cb is the callback that will be used to build the column
|
|
@@ -1918,6 +1946,17 @@ declare class Schema {
|
|
|
1918
1946
|
queryStatements: string[];
|
|
1919
1947
|
sqlType: SqlDataSourceType;
|
|
1920
1948
|
constructor(sqlType?: SqlDataSourceType);
|
|
1949
|
+
/**
|
|
1950
|
+
* @description Adds a raw statement to an operation that will be executed as is
|
|
1951
|
+
* @example
|
|
1952
|
+
* ```ts
|
|
1953
|
+
* schema.rawStatement("CURRENT_TIMESTAMP");
|
|
1954
|
+
* schema.alterTable("users", (table) => {
|
|
1955
|
+
* table.timestamp("created_at").default(this.schema.rawStatement("CURRENT_TIMESTAMP"));
|
|
1956
|
+
* });
|
|
1957
|
+
* ```
|
|
1958
|
+
*/
|
|
1959
|
+
rawStatement(value: string): RawNode;
|
|
1921
1960
|
/**
|
|
1922
1961
|
* @description Add raw query to the migration
|
|
1923
1962
|
*/
|
|
@@ -2037,7 +2076,7 @@ declare class DryQueryBuilder extends QueryBuilder {
|
|
|
2037
2076
|
* @warning This method does not run model or column hooks
|
|
2038
2077
|
* @returns The query builder
|
|
2039
2078
|
*/
|
|
2040
|
-
update(data: Record<string,
|
|
2079
|
+
update(data: Record<string, WriteQueryParam>): this;
|
|
2041
2080
|
/**
|
|
2042
2081
|
* @description Builds the delete query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
|
|
2043
2082
|
* @warning This method does not run model or column hooks
|
|
@@ -3107,6 +3146,7 @@ type UpsertOptionsRawBuilder = {
|
|
|
3107
3146
|
};
|
|
3108
3147
|
type DryQueryBuilderWithoutReadOperations = Omit<DryQueryBuilder, "many" | "one" | "oneOrFail" | "first" | "firstOrFail" | "paginate" | "paginateWithCursor" | "exists" | "pluck" | "increment" | "decrement" | "getSum" | "getAvg" | "getMin" | "getMax" | "getCount" | "stream" | "chunk" | "paginate" | "paginateWithCursor" | "exists">;
|
|
3109
3148
|
type DryModelQueryBuilderWithoutReadOperations<T extends Model, A extends Record<string, any> = {}, R extends Record<string, any> = {}> = Omit<DryModelQueryBuilder<T, A, R>, "many" | "one" | "oneOrFail" | "first" | "firstOrFail" | "paginate" | "paginateWithCursor" | "exists" | "pluck" | "upsert" | "upsertMany" | "increment" | "decrement" | "getSum" | "getAvg" | "getMin" | "getMax" | "getCount" | "stream" | "chunk" | "paginate" | "paginateWithCursor" | "exists">;
|
|
3149
|
+
type WriteQueryParam$1 = string | number | boolean | Date | RawNode | object | null | undefined;
|
|
3110
3150
|
|
|
3111
3151
|
declare class SqlModelManagerUtils<T extends Model> {
|
|
3112
3152
|
protected dbType: SqlDataSourceType;
|
|
@@ -3709,6 +3749,14 @@ declare class SqlDataSource<D extends SqlDataSourceType = SqlDataSourceType, T e
|
|
|
3709
3749
|
* @description Cached AdminJS instance
|
|
3710
3750
|
*/
|
|
3711
3751
|
private adminJsInstance?;
|
|
3752
|
+
/**
|
|
3753
|
+
* @description Callback to handle slave server failures
|
|
3754
|
+
*/
|
|
3755
|
+
private onSlaveServerFailure?;
|
|
3756
|
+
/**
|
|
3757
|
+
* @description Returns the configured slave failure callback
|
|
3758
|
+
*/
|
|
3759
|
+
getOnSlaveServerFailure(): ((error: Error, context: SlaveContext) => void | Promise<void>) | undefined;
|
|
3712
3760
|
/**
|
|
3713
3761
|
* @description Returns the primary instance of the SqlDataSource (set via connect with setPrimary: true)
|
|
3714
3762
|
* All models by default will use this instance to execute queries unless you pass a different connection/transaction in the query options
|
|
@@ -3938,10 +3986,16 @@ declare class SqlDataSource<D extends SqlDataSourceType = SqlDataSourceType, T e
|
|
|
3938
3986
|
*/
|
|
3939
3987
|
rawQuery<R = RawQueryResponseType<D>>(query: string, params?: any[], options?: RawQueryOptions): Promise<R>;
|
|
3940
3988
|
/**
|
|
3941
|
-
* @description Adds a raw statement to an operation
|
|
3989
|
+
* @description Adds a raw statement to an operation that will be executed as is
|
|
3942
3990
|
* @example
|
|
3943
3991
|
* ```ts
|
|
3944
|
-
* await
|
|
3992
|
+
* await sql.query("users").where("name", sql.rawStatement("LOWER(name)"));
|
|
3993
|
+
* await sql.query("users").update({
|
|
3994
|
+
* name: sql.rawStatement("LOWER(name)"),
|
|
3995
|
+
* });
|
|
3996
|
+
* await sql.query("users").insert({
|
|
3997
|
+
* name: sql.rawStatement("LOWER(name)"),
|
|
3998
|
+
* });
|
|
3945
3999
|
* ```
|
|
3946
4000
|
*/
|
|
3947
4001
|
rawStatement(value: string): RawNode;
|
|
@@ -3995,6 +4049,12 @@ declare class SqlDataSource<D extends SqlDataSourceType = SqlDataSourceType, T e
|
|
|
3995
4049
|
* @description Introspects table primary key from the database
|
|
3996
4050
|
*/
|
|
3997
4051
|
getPrimaryKeyInfo(table: string): Promise<TablePrimaryKeyInfo | undefined>;
|
|
4052
|
+
/**
|
|
4053
|
+
* @description Executes an operation on a slave, handling failures with the configured callback
|
|
4054
|
+
* @param operation The operation to execute on the slave
|
|
4055
|
+
* @returns The result of the operation, or falls back to master if slave fails
|
|
4056
|
+
*/
|
|
4057
|
+
private executeOnSlave;
|
|
3998
4058
|
/**
|
|
3999
4059
|
* @description Internal method to establish connection without setting as primary instance
|
|
4000
4060
|
* @description Used by connectToSecondarySource and useConnection
|
|
@@ -4328,18 +4388,18 @@ declare class QueryBuilder<T extends Model = any> extends JsonQueryBuilder<T> {
|
|
|
4328
4388
|
*/
|
|
4329
4389
|
withMaterialized(alias: string, cb: (qb: QueryBuilder<T>) => void): this;
|
|
4330
4390
|
/**
|
|
4331
|
-
* @description Insert record into a table
|
|
4391
|
+
* @description Insert record into a table, you can use raw statements in the data object for literal references to other columns
|
|
4332
4392
|
* @param returning - The columns to return from the query, only supported by postgres and cockroachdb - default is "*"
|
|
4333
4393
|
* @returns raw driver response
|
|
4334
4394
|
*/
|
|
4335
|
-
insert(data: Record<string,
|
|
4395
|
+
insert(data: Record<string, WriteQueryParam$1>, returning?: string[]): Promise<T>;
|
|
4336
4396
|
/**
|
|
4337
4397
|
* @description Insert multiple records into a table
|
|
4338
4398
|
* @param returning - The columns to return from the query, only supported by postgres and cockroachdb - default is "*"
|
|
4339
4399
|
* @returns raw driver response
|
|
4340
4400
|
* @oracledb may do multiple inserts with auto-generated identity columns
|
|
4341
4401
|
*/
|
|
4342
|
-
insertMany(data: Record<string,
|
|
4402
|
+
insertMany(data: Record<string, WriteQueryParam$1>[], returning?: string[]): Promise<T[]>;
|
|
4343
4403
|
/**
|
|
4344
4404
|
* @description Updates or creates a new record using upsert functionality
|
|
4345
4405
|
* @param data The data to insert or update
|
|
@@ -4361,10 +4421,10 @@ declare class QueryBuilder<T extends Model = any> extends JsonQueryBuilder<T> {
|
|
|
4361
4421
|
*/
|
|
4362
4422
|
private executeMssqlMergeRaw;
|
|
4363
4423
|
/**
|
|
4364
|
-
* @description Updates records from a table
|
|
4424
|
+
* @description Updates records from a table, you can use raw statements in the data object for literal references to other columns
|
|
4365
4425
|
* @returns the number of affected rows
|
|
4366
4426
|
*/
|
|
4367
|
-
update(data: Record<string,
|
|
4427
|
+
update(data: Record<string, WriteQueryParam$1>): Promise<number>;
|
|
4368
4428
|
/**
|
|
4369
4429
|
* @description Deletes all records from a table
|
|
4370
4430
|
* @warning This operation does not trigger any hook
|
|
@@ -4456,6 +4516,13 @@ declare class QueryBuilder<T extends Model = any> extends JsonQueryBuilder<T> {
|
|
|
4456
4516
|
*/
|
|
4457
4517
|
protected executePaginateQueries<M, C>(modelsQuery: () => Promise<M>, countQuery: () => Promise<C>): Promise<[M, C]>;
|
|
4458
4518
|
protected getSqlDataSource(mode: "read" | "write"): Promise<SqlDataSource>;
|
|
4519
|
+
/**
|
|
4520
|
+
* @description Executes SQL with slave failure handling
|
|
4521
|
+
* @param mode The operation mode (read or write)
|
|
4522
|
+
* @param operation The execSql operation to perform
|
|
4523
|
+
* @returns The result of the operation
|
|
4524
|
+
*/
|
|
4525
|
+
protected execSqlWithSlaveHandling<R>(mode: "read" | "write", operation: (dataSource: SqlDataSource) => Promise<R>): Promise<R>;
|
|
4459
4526
|
}
|
|
4460
4527
|
|
|
4461
4528
|
type UnionCallBack<T extends Model> = (queryBuilder: QueryBuilder<T>) => QueryBuilder<T>;
|
|
@@ -5934,4 +6001,4 @@ declare const generateOpenApiModelWithMetadata: <T extends new () => Model>(mode
|
|
|
5934
6001
|
$id?: string;
|
|
5935
6002
|
}>;
|
|
5936
6003
|
|
|
5937
|
-
export { type AdminJsActionOptions, type AdminJsAssets, type AdminJsBranding, type AdminJsInstance, type AdminJsLocale, type AdminJsOptions, type AdminJsPage, type AdminJsPropertyOptions, type AdminJsResourceOptions, type AdminJsSettings, type AnnotatedModel, type AsymmetricEncryptionOptions, AutogeneratedModel, type BaseModelMethodOptions, type BaseModelRelationType, type CacheAdapter, type CacheKeys, 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, DryModelQueryBuilder, DryQueryBuilder, type FetchHooks, type GetConnectionReturnType, HysteriaError, InMemoryAdapter, type IndexType, type LazyRelationType, type ManyOptions, type ManyToManyOptions, type ManyToManyStringOptions, Migration, Model, type ModelInstanceType, ModelQueryBuilder, type ModelWithoutRelations, MongoDataSource, type MongoDataSourceInput$1 as MongoDataSourceInput, type MssqlConnectionInstance, type MssqlDataSourceInput, type MssqlPoolInstance, type MysqlConnectionInstance, type MysqlSqlDataSourceInput, type NotNullableMysqlSqlDataSourceInput, type NotNullableOracleDBDataSourceInput, type NotNullableOracleMssqlDataSourceInput, type NotNullablePostgresSqlDataSourceInput, type NotNullableSqliteDataSourceInput, type NumberModelKey, type OneOptions, type OracleDBDataSourceInput, type OracleDBPoolInstance, type PgPoolClientInstance, type PostgresSqlDataSourceInput, QueryBuilder, type RawModelOptions, RawNode, type RawQueryOptions, RedisCacheAdapter, type RedisFetchable, type RedisStorable, type RelatedInstance, type RelationQueryBuilderType, type ReplicationType, type SlaveAlgorithm, type SqlCloneOptions, SqlDataSource, type SqlDataSourceInput, type SqlDataSourceModel, type SqlDataSourceType, type SqlDriverSpecificOptions, type SqlPoolType, type Sqlite3ConnectionOptions, type SqliteConnectionInstance, type SqliteDataSourceInput, type StartTransactionOptions, type SymmetricEncryptionOptions, type TableFormat, type ThroughModel, TimestampedModel, Transaction, type TransactionExecutionOptions, type UniqueType, type UseCacheReturnType, type UseConnectionInput, UserMixin, UuidModel, belongsTo, column, createModelFactory, defineMigrator, generateOpenApiModel, generateOpenApiModelSchema, generateOpenApiModelWithMetadata, getCollectionProperties, getIndexes, getModelColumns, type getPoolReturnType, getPrimaryKey, getRelations, getRelationsMetadata, getUniques, hasMany, hasOne, index, HysteriaLogger as logger, manyToMany, property, RedisDataSource as redis, unique, view, withPerformance };
|
|
6004
|
+
export { type AdminJsActionOptions, type AdminJsAssets, type AdminJsBranding, type AdminJsInstance, type AdminJsLocale, type AdminJsOptions, type AdminJsPage, type AdminJsPropertyOptions, type AdminJsResourceOptions, type AdminJsSettings, type AnnotatedModel, type AsymmetricEncryptionOptions, AutogeneratedModel, type BaseModelMethodOptions, type BaseModelRelationType, type CacheAdapter, type CacheKeys, 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, DryModelQueryBuilder, DryQueryBuilder, type FetchHooks, type GetConnectionReturnType, HysteriaError, InMemoryAdapter, type IndexType, type LazyRelationType, type ManyOptions, type ManyToManyOptions, type ManyToManyStringOptions, Migration, Model, type ModelInstanceType, ModelQueryBuilder, type ModelWithoutRelations, MongoDataSource, type MongoDataSourceInput$1 as MongoDataSourceInput, type MssqlConnectionInstance, type MssqlDataSourceInput, type MssqlPoolInstance, type MysqlConnectionInstance, type MysqlSqlDataSourceInput, type NotNullableMysqlSqlDataSourceInput, type NotNullableOracleDBDataSourceInput, type NotNullableOracleMssqlDataSourceInput, type NotNullablePostgresSqlDataSourceInput, type NotNullableSqliteDataSourceInput, type NumberModelKey, type OneOptions, type OracleDBDataSourceInput, type OracleDBPoolInstance, type PgPoolClientInstance, type PostgresSqlDataSourceInput, QueryBuilder, type RawModelOptions, RawNode, type RawQueryOptions, RedisCacheAdapter, type RedisFetchable, type RedisStorable, type RelatedInstance, type RelationQueryBuilderType, type ReplicationType, 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 SymmetricEncryptionOptions, type TableFormat, type ThroughModel, TimestampedModel, Transaction, type TransactionExecutionOptions, type UniqueType, type UseCacheReturnType, type UseConnectionInput, UserMixin, UuidModel, belongsTo, column, createModelFactory, defineMigrator, generateOpenApiModel, generateOpenApiModelSchema, generateOpenApiModelWithMetadata, getCollectionProperties, getIndexes, getModelColumns, type getPoolReturnType, getPrimaryKey, getRelations, getRelationsMetadata, getUniques, hasMany, hasOne, index, HysteriaLogger as logger, manyToMany, property, RedisDataSource as redis, unique, view, withPerformance };
|