hysteria-orm 10.6.0 → 10.6.2
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 +24 -24
- package/lib/cli.js.map +1 -1
- package/lib/index.cjs +14 -14
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +119 -165
- package/lib/index.d.ts +119 -165
- package/lib/index.js +14 -14
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/index.d.cts
CHANGED
|
@@ -2579,11 +2579,11 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
|
|
|
2579
2579
|
time: number;
|
|
2580
2580
|
}>;
|
|
2581
2581
|
insert: (data: Record<string, any>, returnType?: "millis" | "seconds") => Promise<{
|
|
2582
|
-
data:
|
|
2582
|
+
data: void;
|
|
2583
2583
|
time: number;
|
|
2584
2584
|
}>;
|
|
2585
2585
|
insertMany: (data: Record<string, any>[], returnType?: "millis" | "seconds") => Promise<{
|
|
2586
|
-
data:
|
|
2586
|
+
data: void;
|
|
2587
2587
|
time: number;
|
|
2588
2588
|
}>;
|
|
2589
2589
|
update: (data: Record<string, any>, returnType?: "millis" | "seconds") => Promise<{
|
|
@@ -2682,6 +2682,9 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
|
|
|
2682
2682
|
* @description Executes the query and retrieves multiple results.
|
|
2683
2683
|
*/
|
|
2684
2684
|
many(): Promise<S[]>;
|
|
2685
|
+
then<TResult1 = S[], TResult2 = never>(onfulfilled?: ((value: S[]) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<TResult1 | TResult2>;
|
|
2686
|
+
catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null | undefined): Promise<S[] | TResult>;
|
|
2687
|
+
finally(onfinally?: (() => void) | null | undefined): Promise<S[]>;
|
|
2685
2688
|
/**
|
|
2686
2689
|
* @description Executes the query and retrieves a single column from the results.
|
|
2687
2690
|
* @param key - The column to retrieve from the results, must be a Model Column
|
|
@@ -2841,14 +2844,16 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
|
|
|
2841
2844
|
* @param returning - The columns to return from the query, only supported by postgres and cockroachdb - default is "*"
|
|
2842
2845
|
* @returns WriteOperation that executes when awaited
|
|
2843
2846
|
*/
|
|
2844
|
-
insert(data: Record<string, WriteQueryParam>, returning
|
|
2847
|
+
insert(data: Record<string, WriteQueryParam>, returning: string[]): WriteOperation<T>;
|
|
2848
|
+
insert(data: Record<string, WriteQueryParam>): WriteOperation<void>;
|
|
2845
2849
|
/**
|
|
2846
2850
|
* @description Insert multiple records into a table
|
|
2847
2851
|
* @param returning - The columns to return from the query, only supported by postgres and cockroachdb - default is "*"
|
|
2848
2852
|
* @returns WriteOperation that executes when awaited
|
|
2849
2853
|
* @oracledb may do multiple inserts with auto-generated identity columns
|
|
2850
2854
|
*/
|
|
2851
|
-
insertMany(data: Record<string, WriteQueryParam>[], returning
|
|
2855
|
+
insertMany(data: Record<string, WriteQueryParam>[], returning: string[]): WriteOperation<T[]>;
|
|
2856
|
+
insertMany(data: Record<string, WriteQueryParam>[]): WriteOperation<void>;
|
|
2852
2857
|
/**
|
|
2853
2858
|
* @description Updates or creates a new record using upsert functionality
|
|
2854
2859
|
* @param data The data to insert or update
|
|
@@ -3289,6 +3294,12 @@ type UniqueType = {
|
|
|
3289
3294
|
columns: string[];
|
|
3290
3295
|
name: string;
|
|
3291
3296
|
};
|
|
3297
|
+
/**
|
|
3298
|
+
* @description A property decorator that constrains the decorated property to type V.
|
|
3299
|
+
* TypeScript infers K from the property name and T from the class, then checks
|
|
3300
|
+
* that the property at key K is assignable to V.
|
|
3301
|
+
*/
|
|
3302
|
+
type TypedPropertyDecorator<V> = <K extends string, T extends Record<K, V>>(target: T, propertyKey: K) => void;
|
|
3292
3303
|
|
|
3293
3304
|
declare abstract class FooterQueryBuilder<T extends Model, S extends Record<string, any> = Record<string, any>> {
|
|
3294
3305
|
protected sqlDataSource: SqlDataSource;
|
|
@@ -4390,7 +4401,7 @@ type PaginateWithCursorOptions<T extends Model, K extends ModelKey<T>> = {
|
|
|
4390
4401
|
};
|
|
4391
4402
|
type UpsertOptionsRawBuilder = {
|
|
4392
4403
|
updateOnConflict?: boolean;
|
|
4393
|
-
returning?: string[];
|
|
4404
|
+
returning?: readonly string[];
|
|
4394
4405
|
};
|
|
4395
4406
|
type WriteQueryParam = string | number | boolean | Date | RawNode | object | null | undefined;
|
|
4396
4407
|
/**
|
|
@@ -4539,17 +4550,20 @@ declare class ModelQueryBuilder<T extends Model, S extends Record<string, any> =
|
|
|
4539
4550
|
};
|
|
4540
4551
|
}): Promise<SelectedModel<T, S, R>>;
|
|
4541
4552
|
many(options?: ManyOptions): Promise<SelectedModel<T, S, R>[]>;
|
|
4553
|
+
then<TResult1 = SelectedModel<T, S, R>[], TResult2 = never>(onfulfilled?: ((value: SelectedModel<T, S, R>[]) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<TResult1 | TResult2>;
|
|
4554
|
+
catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null | undefined): Promise<SelectedModel<T, S, R>[] | TResult>;
|
|
4555
|
+
finally(onfinally?: (() => void) | null | undefined): Promise<SelectedModel<T, S, R>[]>;
|
|
4542
4556
|
chunk(chunkSize: number, options?: ManyOptions): AsyncGenerator<SelectedModel<T, S, R>[] | T[]>;
|
|
4543
4557
|
stream(options?: ManyOptions & StreamOptions): Promise<PassThrough & AsyncGenerator<SelectedModel<T, S, R> | T>>;
|
|
4544
4558
|
paginateWithCursor<K extends ModelKey<T>>(page: number, options?: PaginateWithCursorOptions<T, K>, cursor?: Cursor<T, K>): Promise<[CursorPaginatedData<T, S, R>, Cursor<T, K>]>;
|
|
4545
4559
|
/**
|
|
4546
4560
|
* @description Inserts a new record into the database, it is not advised to use this method directly from the query builder if using a ModelQueryBuilder (`Model.query()`), use the `Model.insert` method instead.
|
|
4547
4561
|
*/
|
|
4548
|
-
insert(
|
|
4562
|
+
insert(modelData: Partial<ModelWithoutRelations<T>>, returning: readonly (ModelKey<T> | "*")[] | undefined): WriteOperation<any>;
|
|
4549
4563
|
/**
|
|
4550
4564
|
* @description Inserts multiple records into the database, it is not advised to use this method directly from the query builder if using a ModelQueryBuilder (`Model.query()`), use the `Model.insertMany` method instead.
|
|
4551
4565
|
*/
|
|
4552
|
-
insertMany(
|
|
4566
|
+
insertMany(modelsData: Partial<ModelWithoutRelations<T>>[], returning: readonly (ModelKey<T> | "*")[] | undefined): WriteOperation<any>;
|
|
4553
4567
|
update(data: Partial<ModelWithoutRelations<T>>, options?: UpdateOptions): WriteOperation<number>;
|
|
4554
4568
|
softDelete(options?: SoftDeleteOptions<T>): WriteOperation<number>;
|
|
4555
4569
|
delete(options?: DeleteOptions): WriteOperation<number>;
|
|
@@ -5367,6 +5381,11 @@ declare class SqlDataSource<D extends SqlDataSourceType = SqlDataSourceType, T e
|
|
|
5367
5381
|
* @param table The table name to query from
|
|
5368
5382
|
*/
|
|
5369
5383
|
query<S extends string>(table: TableFormat<S>, options?: RawModelOptions): QueryBuilder;
|
|
5384
|
+
/**
|
|
5385
|
+
* @description Returns a ModelQueryBuilder instance for the given model
|
|
5386
|
+
* @param Model The model to create the query builder from
|
|
5387
|
+
*/
|
|
5388
|
+
from<T extends typeof Model>(Model: T): ModelQueryBuilder<InstanceType<T>>;
|
|
5370
5389
|
/**
|
|
5371
5390
|
* @description Returns a SchemaBuilder instance for DDL operations
|
|
5372
5391
|
* @description The builder will execute queries when awaited or when .execute() is called
|
|
@@ -5564,84 +5583,6 @@ type ExcludeMethods<T> = {
|
|
|
5564
5583
|
* like save(), delete(), refresh() are not incorrectly included.
|
|
5565
5584
|
*/
|
|
5566
5585
|
type ModelDataProperties = Pick<Model, ExcludeMethods<Model>>;
|
|
5567
|
-
/**
|
|
5568
|
-
* Model instance methods available on query results.
|
|
5569
|
-
* These methods enable CRUD operations on fetched models.
|
|
5570
|
-
*
|
|
5571
|
-
* All query results from Model static methods (find, findOne, findOneOrFail,
|
|
5572
|
-
* findBy, findOneBy, findOneByPrimaryKey, all, first, insert, insertMany,
|
|
5573
|
-
* upsert, upsertMany, updateRecord, softDelete) and from ModelQueryBuilder
|
|
5574
|
-
* (one, many, oneOrFail) include these instance methods.
|
|
5575
|
-
*
|
|
5576
|
-
* @example
|
|
5577
|
-
* ```typescript
|
|
5578
|
-
* // Using instance methods on query results
|
|
5579
|
-
* const user = await User.findOne({ where: { email: "test@example.com" } });
|
|
5580
|
-
* if (user) {
|
|
5581
|
-
* user.mergeProps({ name: "Updated Name" });
|
|
5582
|
-
* await user.save();
|
|
5583
|
-
*
|
|
5584
|
-
* // Or update directly
|
|
5585
|
-
* await user.update({ name: "Another Name" });
|
|
5586
|
-
*
|
|
5587
|
-
* // Refresh from database
|
|
5588
|
-
* await user.refresh();
|
|
5589
|
-
*
|
|
5590
|
-
* // Soft delete or hard delete
|
|
5591
|
-
* await user.softDelete();
|
|
5592
|
-
* // or: await user.delete();
|
|
5593
|
-
* }
|
|
5594
|
-
*
|
|
5595
|
-
* // Works with query builder too
|
|
5596
|
-
* const user2 = await User.query().where("id", 1).oneOrFail();
|
|
5597
|
-
* await user2.update({ status: "inactive" });
|
|
5598
|
-
*
|
|
5599
|
-
* // Works with select projections
|
|
5600
|
-
* const user3 = await User.query().select("id", "name").one();
|
|
5601
|
-
* if (user3) {
|
|
5602
|
-
* await user3.delete(); // Still has access to instance methods
|
|
5603
|
-
* }
|
|
5604
|
-
* ```
|
|
5605
|
-
*
|
|
5606
|
-
* Note: These signatures are simplified versions that don't carry the
|
|
5607
|
-
* `this: T extends Model` constraint, allowing them to work on selected
|
|
5608
|
-
* model results without requiring full Model type compatibility.
|
|
5609
|
-
*/
|
|
5610
|
-
type ModelInstanceMethods<T extends Model> = {
|
|
5611
|
-
/**
|
|
5612
|
-
* Merges the provided data with the model instance.
|
|
5613
|
-
* Does not persist to database - use save() or update() after merging.
|
|
5614
|
-
*/
|
|
5615
|
-
mergeProps: (data: Partial<ModelWithoutRelations<T>>) => void;
|
|
5616
|
-
/**
|
|
5617
|
-
* Saves the model to the database (insert or update based on primary key).
|
|
5618
|
-
* @throws {HysteriaError} If the model has no primary key defined
|
|
5619
|
-
*/
|
|
5620
|
-
save: (options?: Omit<BaseModelMethodOptions, "ignoreHooks">) => Promise<any>;
|
|
5621
|
-
/**
|
|
5622
|
-
* Updates the model in the database with the provided payload.
|
|
5623
|
-
* @throws {HysteriaError} If the model has no primary key or primary key value
|
|
5624
|
-
*/
|
|
5625
|
-
update: (payload: Partial<ModelWithoutRelations<T>>, options?: Omit<BaseModelMethodOptions, "ignoreHooks">) => Promise<void>;
|
|
5626
|
-
/**
|
|
5627
|
-
* Soft deletes the model by setting the soft delete column.
|
|
5628
|
-
* @throws {HysteriaError} If the model has no primary key or primary key value
|
|
5629
|
-
*/
|
|
5630
|
-
softDelete: (softDeleteOptions?: {
|
|
5631
|
-
column?: string;
|
|
5632
|
-
value?: string | number | boolean | Date;
|
|
5633
|
-
}, options?: Omit<BaseModelMethodOptions, "ignoreHooks">) => Promise<void>;
|
|
5634
|
-
/**
|
|
5635
|
-
* Hard deletes the model from the database.
|
|
5636
|
-
* @throws {HysteriaError} If the model has no primary key or primary key value
|
|
5637
|
-
*/
|
|
5638
|
-
delete: (options?: Omit<BaseModelMethodOptions, "ignoreHooks">) => Promise<void>;
|
|
5639
|
-
/**
|
|
5640
|
-
* Refreshes the model from the database, updating all properties with current values.
|
|
5641
|
-
* @throws {HysteriaError} If the model has no primary key or primary key value
|
|
5642
|
-
*/
|
|
5643
|
-
refresh: (options?: Omit<BaseModelMethodOptions, "ignoreHooks">) => Promise<void>;
|
|
5644
|
-
};
|
|
5645
5586
|
/**
|
|
5646
5587
|
* Model data without relation properties.
|
|
5647
5588
|
* Includes only data columns from the model, excluding foreign keys and relation accessors.
|
|
@@ -5649,7 +5590,7 @@ type ModelInstanceMethods<T extends Model> = {
|
|
|
5649
5590
|
type ModelWithoutRelations<T extends Model> = Pick<Omit<T, "*">, ExcludeRelations<Omit<T, "*">>> & ModelDataProperties;
|
|
5650
5591
|
/**
|
|
5651
5592
|
* Return type for Model query/mutation methods.
|
|
5652
|
-
*
|
|
5593
|
+
* Represents data-only properties without any business logic.
|
|
5653
5594
|
*
|
|
5654
5595
|
* This type is used as the return type for:
|
|
5655
5596
|
* - Static find methods: find, findOne, findOneOrFail, findBy, findOneBy, findOneByPrimaryKey
|
|
@@ -5666,15 +5607,15 @@ type ModelWithoutRelations<T extends Model> = Pick<Omit<T, "*">, ExcludeRelation
|
|
|
5666
5607
|
* const allUsers = await User.all();
|
|
5667
5608
|
* const newUser = await User.insert({ name: "John" });
|
|
5668
5609
|
*
|
|
5669
|
-
* //
|
|
5610
|
+
* // Results are plain data objects - use static methods for operations
|
|
5670
5611
|
* if (user1) {
|
|
5671
|
-
* await
|
|
5672
|
-
* await
|
|
5673
|
-
* await
|
|
5612
|
+
* await User.updateRecord(user1, { name: "Jane" });
|
|
5613
|
+
* await User.refresh(user1);
|
|
5614
|
+
* await User.deleteRecord(user1);
|
|
5674
5615
|
* }
|
|
5675
5616
|
* ```
|
|
5676
5617
|
*/
|
|
5677
|
-
type ModelQueryResult<T extends Model> = ModelWithoutRelations<T
|
|
5618
|
+
type ModelQueryResult<T extends Model> = ModelWithoutRelations<T>;
|
|
5678
5619
|
type NumberModelKey<T extends Model> = {
|
|
5679
5620
|
[K in keyof T]: T[K] extends number | bigint ? K : never;
|
|
5680
5621
|
}[keyof T];
|
|
@@ -5981,9 +5922,8 @@ type ComposeBuildSelect<S extends Record<string, any>, T extends Model, Columns
|
|
|
5981
5922
|
/**
|
|
5982
5923
|
* The final result type for ModelQueryBuilder queries.
|
|
5983
5924
|
*
|
|
5984
|
-
* Combines selected columns (S) with loaded relations (R)
|
|
5985
|
-
*
|
|
5986
|
-
* like save(), update(), delete(), etc.
|
|
5925
|
+
* Combines selected columns (S) with loaded relations (R) into a single type.
|
|
5926
|
+
* Query results are plain data objects without business logic.
|
|
5987
5927
|
*
|
|
5988
5928
|
* @typeParam M - The Model type
|
|
5989
5929
|
* @typeParam S - Selected columns type from `select()` calls
|
|
@@ -5992,19 +5932,19 @@ type ComposeBuildSelect<S extends Record<string, any>, T extends Model, Columns
|
|
|
5992
5932
|
* @example
|
|
5993
5933
|
* // User.query().select("name").load("posts").one()
|
|
5994
5934
|
* SelectedModel<User, { name: string }, { posts: Post[] }>
|
|
5995
|
-
* // Result: { name: string; posts: Post[] }
|
|
5935
|
+
* // Result: { name: string; posts: Post[] }
|
|
5996
5936
|
*/
|
|
5997
|
-
type SelectedModel<M extends Model, S extends Record<string, any> = {}, R extends Record<string, any> = {}> = S & R
|
|
5937
|
+
type SelectedModel<M extends Model, S extends Record<string, any> = {}, R extends Record<string, any> = {}> = S & R;
|
|
5998
5938
|
|
|
5999
5939
|
type NullableAndUndefinable<T> = T | (T | null) | (T | undefined) | (T | null | undefined);
|
|
6000
5940
|
type UpsertOptions<T extends Model> = {
|
|
6001
5941
|
ignoreHooks?: boolean;
|
|
6002
5942
|
updateOnConflict?: boolean;
|
|
6003
|
-
returning?:
|
|
5943
|
+
returning?: ReturningKey<T>[];
|
|
6004
5944
|
};
|
|
6005
5945
|
type InsertOptions<T extends Model> = {
|
|
6006
5946
|
ignoreHooks?: boolean;
|
|
6007
|
-
returning?:
|
|
5947
|
+
returning?: ReturningKey<T>[];
|
|
6008
5948
|
};
|
|
6009
5949
|
type ExcludeRelations<T> = {
|
|
6010
5950
|
[K in keyof T]: T[K] extends NullableAndUndefinable<Model> | NullableAndUndefinable<Model[]> | ((...args: any[]) => any) ? never : K;
|
|
@@ -6063,6 +6003,15 @@ type WhereType<T> = BaseWhereType<T> & {
|
|
|
6063
6003
|
type ModelKey<T extends Model> = {
|
|
6064
6004
|
[K in keyof T]: T[K] extends NullableAndUndefinable<Model> | NullableAndUndefinable<Model[]> ? never : K extends "*" ? never : T[K] extends (...args: any[]) => any ? never : K;
|
|
6065
6005
|
}[keyof T];
|
|
6006
|
+
/**
|
|
6007
|
+
* Valid key for the `returning` option: any model column or `"*"` for all columns.
|
|
6008
|
+
*/
|
|
6009
|
+
type ReturningKey<T extends Model> = ModelKey<T> | "*";
|
|
6010
|
+
/**
|
|
6011
|
+
* Generic constraint for the `returning` columns parameter.
|
|
6012
|
+
* Used as a generic bound on insert/upsert/write methods.
|
|
6013
|
+
*/
|
|
6014
|
+
type ReturningColumns<T extends Model> = readonly ReturningKey<T>[] | undefined;
|
|
6066
6015
|
/**
|
|
6067
6016
|
* Extracts the value type for a model column key, adding `null` for SQL compatibility.
|
|
6068
6017
|
* Used in type-safe where/having clauses to infer value types from column keys.
|
|
@@ -6087,7 +6036,7 @@ type FindOneType<T extends Model, S extends ModelKey<T>[] = any[], R extends Mod
|
|
|
6087
6036
|
type FindType<T extends Model, S extends ModelKey<T>[] = any[], R extends ModelRelation<T>[] = never[]> = Omit<FindOneType<T, S, R>, "throwErrorOnNull"> & {
|
|
6088
6037
|
limit?: number;
|
|
6089
6038
|
};
|
|
6090
|
-
type FindReturnType<T extends Model, S extends ModelKey<T>[] = any[], R extends ModelRelation<T>[] = never[]> =
|
|
6039
|
+
type FindReturnType<T extends Model, S extends ModelKey<T>[] = any[], R extends ModelRelation<T>[] = never[]> = S extends readonly any[] ? S[number] extends never ? ModelWithoutRelations<T> & {
|
|
6091
6040
|
[K in R[number] & keyof T]: T[K];
|
|
6092
6041
|
} : {
|
|
6093
6042
|
[K in S[number] & keyof T]: T[K];
|
|
@@ -6095,7 +6044,19 @@ type FindReturnType<T extends Model, S extends ModelKey<T>[] = any[], R extends
|
|
|
6095
6044
|
[K in R[number] & keyof T]: T[K];
|
|
6096
6045
|
} : ModelWithoutRelations<T> & {
|
|
6097
6046
|
[K in R[number] & keyof T]: T[K];
|
|
6098
|
-
}
|
|
6047
|
+
};
|
|
6048
|
+
/**
|
|
6049
|
+
* Return type for write operations (insert/upsert) based on the returning columns.
|
|
6050
|
+
* - `undefined` or `[]` -> `void` (no data fetched)
|
|
6051
|
+
* - `["*"]` -> `ModelQueryResult<T>` (full model)
|
|
6052
|
+
* - `["col1", "col2"]` -> `{ col1: ...; col2: ... } & ModelDataProperties`
|
|
6053
|
+
*
|
|
6054
|
+
* @typeParam T - The Model type
|
|
6055
|
+
* @typeParam R - The returning columns array (literal tuple for type inference)
|
|
6056
|
+
*/
|
|
6057
|
+
type WriteReturnType<T extends Model, R extends ReturningColumns<T>> = R extends undefined ? void : R extends readonly [] ? void : R extends readonly ReturningKey<T>[] ? "*" extends R[number] ? ModelQueryResult<T> : {
|
|
6058
|
+
[K in R[number] & keyof T]: T[K];
|
|
6059
|
+
} & ModelDataProperties : never;
|
|
6099
6060
|
|
|
6100
6061
|
/**
|
|
6101
6062
|
* @description Represents a Table in the Database
|
|
@@ -6196,8 +6157,13 @@ declare abstract class Model<T extends Model<T> = any> extends Entity {
|
|
|
6196
6157
|
* @mysql If no Primary Key is present in the model definition, the model will be returned
|
|
6197
6158
|
* @sqlite If no Primary Key is present in the model definition, the model will be returned
|
|
6198
6159
|
* @sqlite Returning Not supported and won't have effect
|
|
6160
|
+
* @typeParam T - The Model type
|
|
6161
|
+
* @typeParam R - The returning columns (literal tuple for type inference)
|
|
6199
6162
|
*/
|
|
6200
|
-
static insert<T extends Model>(this: new () => T | typeof Model, modelData: Partial<ModelWithoutRelations<T>>, options?: BaseModelMethodOptions &
|
|
6163
|
+
static insert<T extends Model, const R extends ReturningColumns<T> = undefined>(this: new () => T | typeof Model, modelData: Partial<ModelWithoutRelations<T>>, options?: BaseModelMethodOptions & {
|
|
6164
|
+
ignoreHooks?: boolean;
|
|
6165
|
+
returning?: R;
|
|
6166
|
+
}): WriteOperation<WriteReturnType<T, R>>;
|
|
6201
6167
|
/**
|
|
6202
6168
|
* @description Saves multiple records to the database
|
|
6203
6169
|
* @warning If not using postgres and the model has no primary key, the models will be saved, but it won't be possible to retrieve them so at that point they will be returned as an empty array
|
|
@@ -6205,8 +6171,13 @@ declare abstract class Model<T extends Model<T> = any> extends Entity {
|
|
|
6205
6171
|
* @sqlite If no Primary Key is present in the model definition, the model will be returned
|
|
6206
6172
|
* @sqlite Returning Not supported and won't have effect
|
|
6207
6173
|
* @oracledb may do multiple inserts with auto-generated identity columns
|
|
6174
|
+
* @typeParam T - The Model type
|
|
6175
|
+
* @typeParam R - The returning columns (literal tuple for type inference)
|
|
6208
6176
|
*/
|
|
6209
|
-
static insertMany<T extends Model>(this: new () => T | typeof Model, modelsData: Partial<ModelWithoutRelations<T>>[], options?: BaseModelMethodOptions &
|
|
6177
|
+
static insertMany<T extends Model, const R extends ReturningColumns<T> = undefined>(this: new () => T | typeof Model, modelsData: Partial<ModelWithoutRelations<T>>[], options?: BaseModelMethodOptions & {
|
|
6178
|
+
ignoreHooks?: boolean;
|
|
6179
|
+
returning?: R;
|
|
6180
|
+
}): WriteOperation<R extends readonly [] ? void : WriteReturnType<T, R>[]>;
|
|
6210
6181
|
/**
|
|
6211
6182
|
* @description Syncs in the through table the given models for the given relation
|
|
6212
6183
|
* @param relation The many to many relation to sync, this is not type safe since many to many relations defined at a decorator level
|
|
@@ -6240,17 +6211,32 @@ declare abstract class Model<T extends Model<T> = any> extends Entity {
|
|
|
6240
6211
|
} : T>;
|
|
6241
6212
|
/**
|
|
6242
6213
|
* @description Updates or creates a new record, if no searchCriteria payload is provided, provided data will be inserted as is
|
|
6214
|
+
* @typeParam R - The returning columns (literal tuple for type inference). Defaults to void.
|
|
6243
6215
|
*/
|
|
6244
|
-
static upsert<T extends Model>(this: new () => T | typeof Model, searchCriteria: Partial<ModelWithoutRelations<T>>, data: Partial<ModelWithoutRelations<T>>, options?: UpsertOptions<T> & BaseModelMethodOptions
|
|
6216
|
+
static upsert<T extends Model, const R extends ReturningColumns<T> = undefined>(this: new () => T | typeof Model, searchCriteria: Partial<ModelWithoutRelations<T>>, data: Partial<ModelWithoutRelations<T>>, options?: Omit<UpsertOptions<T>, "returning"> & BaseModelMethodOptions & {
|
|
6217
|
+
returning?: R;
|
|
6218
|
+
}): Promise<WriteReturnType<T, R>>;
|
|
6245
6219
|
/**
|
|
6246
6220
|
* @description Updates or creates multiple records
|
|
6247
6221
|
* @param {updateOnConflict} If true, the record will be updated if it exists, otherwise it will be ignored
|
|
6222
|
+
* @typeParam R - The returning columns (literal tuple for type inference). Defaults to void.
|
|
6248
6223
|
*/
|
|
6249
|
-
static upsertMany<T extends Model>(this: new () => T | typeof Model, conflictColumns: ModelKey<T>[], data: Partial<ModelWithoutRelations<T>>[], options?: UpsertOptions<T> & BaseModelMethodOptions
|
|
6224
|
+
static upsertMany<T extends Model, const R extends ReturningColumns<T> = undefined>(this: new () => T | typeof Model, conflictColumns: ModelKey<T>[], data: Partial<ModelWithoutRelations<T>>[], options?: Omit<UpsertOptions<T>, "returning"> & BaseModelMethodOptions & {
|
|
6225
|
+
returning?: R;
|
|
6226
|
+
}): Promise<WriteReturnType<T, R>[]>;
|
|
6250
6227
|
/**
|
|
6251
6228
|
* @description Deletes a record to the database
|
|
6252
6229
|
*/
|
|
6253
6230
|
static deleteRecord<T extends Model>(this: new () => T | typeof Model, modelSqlInstance: T, options?: Omit<BaseModelMethodOptions, "ignoreHooks">): Promise<void>;
|
|
6231
|
+
/**
|
|
6232
|
+
* @description Saves (inserts or updates) a model instance to the database
|
|
6233
|
+
* @description If the primary key is not set, performs an insert. If set, performs an update.
|
|
6234
|
+
* @description After saving, the instance is updated with the result from the database
|
|
6235
|
+
* @param modelSqlInstance The model instance to save
|
|
6236
|
+
* @param options Optional transaction, connection, or ignoreHooks options
|
|
6237
|
+
* @throws {HysteriaError} If the model has no primary key defined
|
|
6238
|
+
*/
|
|
6239
|
+
static save<T extends Model>(this: new () => T | typeof Model, modelSqlInstance: Partial<T>, options?: Omit<BaseModelMethodOptions, "ignoreHooks">): Promise<ModelQueryResult<T>>;
|
|
6254
6240
|
/**
|
|
6255
6241
|
* @description Soft Deletes a record to the database
|
|
6256
6242
|
* @description default column: deletedAt
|
|
@@ -6448,38 +6434,6 @@ declare abstract class Model<T extends Model<T> = any> extends Entity {
|
|
|
6448
6434
|
* @description Gives the correct model manager with the correct connection based on the options provided
|
|
6449
6435
|
*/
|
|
6450
6436
|
private static dispatchModelManager;
|
|
6451
|
-
/**
|
|
6452
|
-
* @description Merges the provided data with the model instance
|
|
6453
|
-
*/
|
|
6454
|
-
mergeProps<T extends Model = this>(this: T, data: Partial<ModelWithoutRelations<T>>): void;
|
|
6455
|
-
/**
|
|
6456
|
-
* @description inserts or updates the model to the database, must have a primary key in order to work
|
|
6457
|
-
* @throws {HysteriaError} If the model has no primary key
|
|
6458
|
-
*/
|
|
6459
|
-
save<T extends Model = this>(options?: Omit<BaseModelMethodOptions, "ignoreHooks">): Promise<T>;
|
|
6460
|
-
/**
|
|
6461
|
-
* @description Updates the model in the database, must have a primary key in order to work
|
|
6462
|
-
* @throws {HysteriaError} If the model has no primary key valorized in the instance
|
|
6463
|
-
*/
|
|
6464
|
-
update<T extends Model = this>(payload: Partial<ModelWithoutRelations<T>>, options?: Omit<BaseModelMethodOptions, "ignoreHooks">): Promise<void>;
|
|
6465
|
-
/**
|
|
6466
|
-
* @description Soft deletes the model from the database, must have a primary key in order to work
|
|
6467
|
-
* @throws {HysteriaError} If the model has no primary key valorized in the instance
|
|
6468
|
-
*/
|
|
6469
|
-
softDelete<T extends Model = this>(this: T, softDeleteOptions?: {
|
|
6470
|
-
column?: keyof ModelWithoutRelations<T>;
|
|
6471
|
-
value?: string | number | boolean | Date;
|
|
6472
|
-
}, options?: Omit<BaseModelMethodOptions, "ignoreHooks">): Promise<void>;
|
|
6473
|
-
/**
|
|
6474
|
-
* @description Deletes the model from the database, must have a primary key in order to work
|
|
6475
|
-
* @throws {HysteriaError} If the model has no primary key valorized in the instance
|
|
6476
|
-
*/
|
|
6477
|
-
delete<T extends Model = this>(options?: Omit<BaseModelMethodOptions, "ignoreHooks">): Promise<void>;
|
|
6478
|
-
/**
|
|
6479
|
-
* @description Refreshes the model from the database, it both updates the instance and returns the refreshed model
|
|
6480
|
-
* @throws {HysteriaError} If the model has no primary key valorized in the instance
|
|
6481
|
-
*/
|
|
6482
|
-
refresh<T extends Model = this>(options?: Omit<BaseModelMethodOptions, "ignoreHooks">): Promise<T>;
|
|
6483
6437
|
}
|
|
6484
6438
|
|
|
6485
6439
|
type BaseModelRelationType = {
|
|
@@ -6555,13 +6509,13 @@ declare namespace column {
|
|
|
6555
6509
|
export { _a as enum };
|
|
6556
6510
|
}
|
|
6557
6511
|
declare function primaryKeyColumn(options?: Omit<ColumnOptions, "primaryKey">): PropertyDecorator;
|
|
6558
|
-
declare function floatColumn(options?: Omit<ColumnOptions, "serialize">):
|
|
6512
|
+
declare function floatColumn(options?: Omit<ColumnOptions, "serialize">): TypedPropertyDecorator<number | null | undefined>;
|
|
6559
6513
|
/**
|
|
6560
6514
|
* @description Decorator to define a integer column in the model, this will automatically convert the integer to the correct format for the database
|
|
6561
6515
|
* @description Useful in databases like postgres where the integer is returned as a string by the driver
|
|
6562
6516
|
* @description Defaults type to integer for migration generation
|
|
6563
6517
|
*/
|
|
6564
|
-
declare function integerColumn(options?: Omit<ColumnOptions, "serialize">):
|
|
6518
|
+
declare function integerColumn(options?: Omit<ColumnOptions, "serialize">): TypedPropertyDecorator<number | null | undefined>;
|
|
6565
6519
|
/**
|
|
6566
6520
|
* @description Decorator to define an auto-incrementing integer primary key column
|
|
6567
6521
|
* @description Automatically sets primaryKey: true and nullable: false
|
|
@@ -6569,7 +6523,7 @@ declare function integerColumn(options?: Omit<ColumnOptions, "serialize">): Prop
|
|
|
6569
6523
|
* @postgres SERIAL (INTEGER with auto-increment sequence)
|
|
6570
6524
|
* @sqlite INTEGER PRIMARY KEY AUTOINCREMENT
|
|
6571
6525
|
*/
|
|
6572
|
-
declare function incrementColumn(options?: Omit<ColumnOptions, "serialize" | "primaryKey" | "nullable">):
|
|
6526
|
+
declare function incrementColumn(options?: Omit<ColumnOptions, "serialize" | "primaryKey" | "nullable">): TypedPropertyDecorator<number | null | undefined>;
|
|
6573
6527
|
/**
|
|
6574
6528
|
* @description Decorator to define an auto-incrementing bigint primary key column
|
|
6575
6529
|
* @description Automatically sets primaryKey: true and nullable: false
|
|
@@ -6577,37 +6531,37 @@ declare function incrementColumn(options?: Omit<ColumnOptions, "serialize" | "pr
|
|
|
6577
6531
|
* @postgres BIGSERIAL (BIGINT with auto-increment sequence)
|
|
6578
6532
|
* @sqlite INTEGER PRIMARY KEY AUTOINCREMENT
|
|
6579
6533
|
*/
|
|
6580
|
-
declare function bigIncrementColumn(options?: Omit<ColumnOptions, "serialize" | "primaryKey" | "nullable">):
|
|
6534
|
+
declare function bigIncrementColumn(options?: Omit<ColumnOptions, "serialize" | "primaryKey" | "nullable">): TypedPropertyDecorator<number | null | undefined>;
|
|
6581
6535
|
/**
|
|
6582
6536
|
* @description Decorator to define a uuid column in the model
|
|
6583
6537
|
* @description This will automatically generate a uuid if no value is provided
|
|
6584
6538
|
* @description Defaults type to uuid for migration generation
|
|
6585
6539
|
*/
|
|
6586
|
-
declare function uuidColumn(options?: Omit<ColumnOptions, "prepare">):
|
|
6540
|
+
declare function uuidColumn(options?: Omit<ColumnOptions, "prepare">): TypedPropertyDecorator<string | null | undefined>;
|
|
6587
6541
|
/**
|
|
6588
6542
|
* @description Decorator to define a ulid column in the model
|
|
6589
6543
|
* @description This will automatically generate a ulid if no value is provided
|
|
6590
6544
|
* @description Defaults type to ulid for migration generation
|
|
6591
6545
|
*/
|
|
6592
|
-
declare function ulidColumn(options?: Omit<ColumnOptions, "prepare">):
|
|
6546
|
+
declare function ulidColumn(options?: Omit<ColumnOptions, "prepare">): TypedPropertyDecorator<string | null | undefined>;
|
|
6593
6547
|
/**
|
|
6594
6548
|
* @description Decorator to define a string (varchar) column in the model
|
|
6595
6549
|
* @description Defaults type to string for migration generation
|
|
6596
6550
|
*/
|
|
6597
6551
|
declare function stringColumn(options?: Omit<ColumnOptions, "type"> & {
|
|
6598
6552
|
length?: number;
|
|
6599
|
-
}):
|
|
6553
|
+
}): TypedPropertyDecorator<string | null | undefined>;
|
|
6600
6554
|
/**
|
|
6601
6555
|
* @description Decorator to define a text column in the model for longer text content
|
|
6602
6556
|
* @description Defaults type to longtext for migration generation
|
|
6603
6557
|
*/
|
|
6604
|
-
declare function textColumn(options?: Omit<ColumnOptions, "type">):
|
|
6558
|
+
declare function textColumn(options?: Omit<ColumnOptions, "type">): TypedPropertyDecorator<string | null | undefined>;
|
|
6605
6559
|
/**
|
|
6606
6560
|
* @description Decorator to define a bigint column in the model
|
|
6607
6561
|
* @description Useful in databases like postgres where the bigint is returned as a string by the driver
|
|
6608
6562
|
* @description Defaults type to bigint for migration generation
|
|
6609
6563
|
*/
|
|
6610
|
-
declare function bigintColumn(options?: Omit<ColumnOptions, "serialize">):
|
|
6564
|
+
declare function bigintColumn(options?: Omit<ColumnOptions, "serialize">): TypedPropertyDecorator<number | bigint | null | undefined>;
|
|
6611
6565
|
/**
|
|
6612
6566
|
* @description Decorator to define a decimal column in the model for precise numeric values
|
|
6613
6567
|
* @description Useful for financial data and other precise calculations
|
|
@@ -6618,37 +6572,37 @@ declare function bigintColumn(options?: Omit<ColumnOptions, "serialize">): Prope
|
|
|
6618
6572
|
declare function decimalColumn(options?: Omit<ColumnOptions, "serialize"> & {
|
|
6619
6573
|
precision?: number;
|
|
6620
6574
|
scale?: number;
|
|
6621
|
-
}):
|
|
6575
|
+
}): TypedPropertyDecorator<number | null | undefined>;
|
|
6622
6576
|
/**
|
|
6623
6577
|
* @description Decorator to define a binary/blob column in the model
|
|
6624
6578
|
* @description Defaults type to binary for migration generation
|
|
6625
6579
|
*/
|
|
6626
|
-
declare function binaryColumn(options?: Omit<ColumnOptions, "type">):
|
|
6580
|
+
declare function binaryColumn(options?: Omit<ColumnOptions, "type">): TypedPropertyDecorator<Buffer | Uint8Array | string | null | undefined>;
|
|
6627
6581
|
/**
|
|
6628
6582
|
* @description Decorator to define an enum column in the model
|
|
6629
6583
|
* @description Defaults type to enum for migration generation
|
|
6630
6584
|
* @param values The allowed enum values
|
|
6631
6585
|
* @param options Additional column options
|
|
6632
6586
|
*/
|
|
6633
|
-
declare function enumColumn
|
|
6587
|
+
declare function enumColumn<const V extends readonly string[]>(values: V, options?: Omit<ColumnOptions, "type">): TypedPropertyDecorator<V[number] | null | undefined>;
|
|
6634
6588
|
/**
|
|
6635
6589
|
* @description Decorator to define a symmetric encrypted column in the model with a key
|
|
6636
6590
|
* @description This will automatically encrypt the value before it is inserted or updated in the database and decrypt it when it is retrieved from the database
|
|
6637
6591
|
* @description If no value is provided, the value will be returned as is
|
|
6638
6592
|
*/
|
|
6639
|
-
declare function symmetric(options: Omit<SymmetricEncryptionOptions, "prepare" | "serialize">):
|
|
6593
|
+
declare function symmetric(options: Omit<SymmetricEncryptionOptions, "prepare" | "serialize">): TypedPropertyDecorator<string | null | undefined>;
|
|
6640
6594
|
/**
|
|
6641
6595
|
* @description Decorator to define a asymmetric encrypted column in the model with public and private keys
|
|
6642
6596
|
* @description This will automatically encrypt the value before it is inserted or updated in the database and decrypt it when it is retrieved from the database
|
|
6643
6597
|
* @description If no value is provided, the value will be returned as is
|
|
6644
6598
|
*/
|
|
6645
|
-
declare function asymmetric(options: Omit<AsymmetricEncryptionOptions, "prepare" | "serialize">):
|
|
6599
|
+
declare function asymmetric(options: Omit<AsymmetricEncryptionOptions, "prepare" | "serialize">): TypedPropertyDecorator<string | null | undefined>;
|
|
6646
6600
|
/**
|
|
6647
6601
|
* @description Decorator to define a boolean column in the model
|
|
6648
6602
|
* @description This will automatically convert the boolean to the correct format for the database, useful for mysql since it stores booleans as tinyint(1)
|
|
6649
6603
|
* @description Defaults type to boolean for migration generation
|
|
6650
6604
|
*/
|
|
6651
|
-
declare function booleanColumn(options?: Omit<ColumnOptions, "prepare" | "serialize">):
|
|
6605
|
+
declare function booleanColumn(options?: Omit<ColumnOptions, "prepare" | "serialize">): TypedPropertyDecorator<boolean | null | undefined>;
|
|
6652
6606
|
/**
|
|
6653
6607
|
* @description Decorator to define a DATE_ONLY column in the model (YYYY-MM-DD)
|
|
6654
6608
|
* @description This will automatically convert the date to DATE_ONLY format
|
|
@@ -6661,7 +6615,7 @@ declare function booleanColumn(options?: Omit<ColumnOptions, "prepare" | "serial
|
|
|
6661
6615
|
* @param options.prepare Optional custom prepare function that receives the pre-handled value
|
|
6662
6616
|
* @param options.serialize Optional custom serialize function that receives the pre-handled value
|
|
6663
6617
|
*/
|
|
6664
|
-
declare function dateOnlyColumn(options?: Omit<DateColumnOptions, "format">):
|
|
6618
|
+
declare function dateOnlyColumn(options?: Omit<DateColumnOptions, "format">): TypedPropertyDecorator<Date | string | null | undefined>;
|
|
6665
6619
|
/**
|
|
6666
6620
|
* @description Decorator to define a DATETIME column in the model (YYYY-MM-DD HH:mm:ss)
|
|
6667
6621
|
* @description This will automatically convert the date to ISO format
|
|
@@ -6674,7 +6628,7 @@ declare function dateOnlyColumn(options?: Omit<DateColumnOptions, "format">): Pr
|
|
|
6674
6628
|
* @param options.prepare Optional custom prepare function that receives the pre-handled value
|
|
6675
6629
|
* @param options.serialize Optional custom serialize function that receives the pre-handled value
|
|
6676
6630
|
*/
|
|
6677
|
-
declare function datetimeColumn(options?: Omit<DateColumnOptions, "format">):
|
|
6631
|
+
declare function datetimeColumn(options?: Omit<DateColumnOptions, "format">): TypedPropertyDecorator<Date | string | null | undefined>;
|
|
6678
6632
|
/**
|
|
6679
6633
|
* @description Decorator to define a TIMESTAMP column in the model (Unix timestamp)
|
|
6680
6634
|
* @description This will automatically convert the date to Unix timestamp format
|
|
@@ -6687,7 +6641,7 @@ declare function datetimeColumn(options?: Omit<DateColumnOptions, "format">): Pr
|
|
|
6687
6641
|
* @param options.prepare Optional custom prepare function that receives the pre-handled value
|
|
6688
6642
|
* @param options.serialize Optional custom serialize function that receives the pre-handled value
|
|
6689
6643
|
*/
|
|
6690
|
-
declare function timestampColumn(options?: Omit<DateColumnOptions, "format">):
|
|
6644
|
+
declare function timestampColumn(options?: Omit<DateColumnOptions, "format">): TypedPropertyDecorator<Date | string | null | undefined>;
|
|
6691
6645
|
/**
|
|
6692
6646
|
* @description Decorator to define a TIME_ONLY column in the model (HH:mm:ss)
|
|
6693
6647
|
* @description This will automatically convert the date to TIME_ONLY format
|
|
@@ -6700,14 +6654,14 @@ declare function timestampColumn(options?: Omit<DateColumnOptions, "format">): P
|
|
|
6700
6654
|
* @param options.prepare Optional custom prepare function that receives the pre-handled value
|
|
6701
6655
|
* @param options.serialize Optional custom serialize function that receives the pre-handled value
|
|
6702
6656
|
*/
|
|
6703
|
-
declare function timeOnlyColumn(options?: Omit<DateColumnOptions, "format">):
|
|
6657
|
+
declare function timeOnlyColumn(options?: Omit<DateColumnOptions, "format">): TypedPropertyDecorator<Date | string | null | undefined>;
|
|
6704
6658
|
/**
|
|
6705
6659
|
* @description Decorator to define a json column in the model
|
|
6706
6660
|
* @description This will automatically convert the json to the correct format for the database
|
|
6707
6661
|
* @throws json parse error if the value from the database is not valid json
|
|
6708
6662
|
* @description Defaults type to jsonb for migration generation
|
|
6709
6663
|
*/
|
|
6710
|
-
declare function jsonColumn(options?: Omit<ColumnOptions, "prepare" | "serialize">):
|
|
6664
|
+
declare function jsonColumn(options?: Omit<ColumnOptions, "prepare" | "serialize">): TypedPropertyDecorator<unknown>;
|
|
6711
6665
|
declare function getModelColumns(target: typeof Model): ColumnType[];
|
|
6712
6666
|
/**
|
|
6713
6667
|
* relations
|
|
@@ -6720,22 +6674,22 @@ declare function getModelColumns(target: typeof Model): ColumnType[];
|
|
|
6720
6674
|
* belongsTo<typeof Post>(() => User, 'userId')
|
|
6721
6675
|
* ```
|
|
6722
6676
|
*/
|
|
6723
|
-
declare function belongsTo<M extends typeof Model = any, R extends typeof Model = any>(model: () => R, foreignKey?: ModelKey<InstanceType<M>>, options?: BaseModelRelationType):
|
|
6724
|
-
declare function belongsTo<R extends typeof Model = any>(model: () => R, foreignKey?: string, options?: BaseModelRelationType):
|
|
6677
|
+
declare function belongsTo<M extends typeof Model = any, R extends typeof Model = any>(model: () => R, foreignKey?: ModelKey<InstanceType<M>>, options?: BaseModelRelationType): TypedPropertyDecorator<InstanceType<R> | null | undefined>;
|
|
6678
|
+
declare function belongsTo<R extends typeof Model = any>(model: () => R, foreignKey?: string, options?: BaseModelRelationType): TypedPropertyDecorator<InstanceType<R> | null | undefined>;
|
|
6725
6679
|
/**
|
|
6726
6680
|
* @description Establishes a has one relation with the given model
|
|
6727
6681
|
* @default foreignKey by default will be the singular of the model name plus "_id"
|
|
6728
6682
|
* @example User will have foreignKey "user_id" on the Post model
|
|
6729
6683
|
*/
|
|
6730
|
-
declare function hasOne<T extends typeof Model>(model: () => T, foreignKey?: ModelKey<InstanceType<T>>):
|
|
6731
|
-
declare function hasOne<T extends typeof Model>(model: () => T, foreignKey?: string):
|
|
6684
|
+
declare function hasOne<T extends typeof Model>(model: () => T, foreignKey?: ModelKey<InstanceType<T>>): TypedPropertyDecorator<InstanceType<T> | null | undefined>;
|
|
6685
|
+
declare function hasOne<T extends typeof Model>(model: () => T, foreignKey?: string): TypedPropertyDecorator<InstanceType<T> | null | undefined>;
|
|
6732
6686
|
/**
|
|
6733
6687
|
* @description Establishes a has many relation with the given model
|
|
6734
6688
|
* @default foreignKey by default will be the singular of the model name plus "_id"
|
|
6735
6689
|
* @example User will have foreignKey "user_id" on the Post model
|
|
6736
6690
|
*/
|
|
6737
|
-
declare function hasMany<T extends typeof Model>(model: () => T, foreignKey?: ModelKey<InstanceType<T>>):
|
|
6738
|
-
declare function hasMany<T extends typeof Model>(model: () => T, foreignKey?: string):
|
|
6691
|
+
declare function hasMany<T extends typeof Model>(model: () => T, foreignKey?: ModelKey<InstanceType<T>>): TypedPropertyDecorator<InstanceType<T>[] | null | undefined>;
|
|
6692
|
+
declare function hasMany<T extends typeof Model>(model: () => T, foreignKey?: string): TypedPropertyDecorator<InstanceType<T>[] | null | undefined>;
|
|
6739
6693
|
/**
|
|
6740
6694
|
* @description Establishes a many to many relation with the given model
|
|
6741
6695
|
* @default foreignKey by default will be the singular of the model that establishes the relation name plus "_id"
|
|
@@ -6746,8 +6700,8 @@ declare function hasMany<T extends typeof Model>(model: () => T, foreignKey?: st
|
|
|
6746
6700
|
* @param throughModelKeys.rightForeignKey The foreign key of the through model from the related model (the model you are joining to)
|
|
6747
6701
|
* @example User will have foreignKey "user_id" on the Join table by default
|
|
6748
6702
|
*/
|
|
6749
|
-
declare function manyToMany<R extends typeof Model, T extends typeof Model, TM extends ThroughModel<T>>(model: () => R, throughModel: TM, throughModelKeys?: ManyToManyOptions<T, TM>, options?: BaseModelRelationType):
|
|
6750
|
-
declare function manyToMany<R extends typeof Model>(model: () => R, throughModel: string | (() => typeof Model), throughModelKeys?: ManyToManyStringOptions, options?: BaseModelRelationType):
|
|
6703
|
+
declare function manyToMany<R extends typeof Model, T extends typeof Model, TM extends ThroughModel<T>>(model: () => R, throughModel: TM, throughModelKeys?: ManyToManyOptions<T, TM>, options?: BaseModelRelationType): TypedPropertyDecorator<InstanceType<R>[] | null | undefined>;
|
|
6704
|
+
declare function manyToMany<R extends typeof Model>(model: () => R, throughModel: string | (() => typeof Model), throughModelKeys?: ManyToManyStringOptions, options?: BaseModelRelationType): TypedPropertyDecorator<InstanceType<R>[] | null | undefined>;
|
|
6751
6705
|
declare function getRelationsMetadata(target: typeof Model): LazyRelationType[];
|
|
6752
6706
|
/**
|
|
6753
6707
|
* @description Returns the relations of the model
|
|
@@ -7924,4 +7878,4 @@ declare const generateOpenApiModelWithMetadata: <T extends new () => Model>(mode
|
|
|
7924
7878
|
$id?: string;
|
|
7925
7879
|
}>;
|
|
7926
7880
|
|
|
7927
|
-
export { type AbstractConstructor, type AdminJsActionOptions, type AdminJsAssets, type AdminJsBranding, type AdminJsInstance, type AdminJsLocale, type AdminJsOptions, type AdminJsPage, type AdminJsPropertyOptions, type AdminJsResourceOptions, type AdminJsSettings, type AnyConstructor, type AsymmetricEncryptionOptions, type BaseModelMethodOptions, type BaseModelRelationType, BaseSeeder, type BigIntFields, BigIntMixin, type BuildSelectType, type BuildSingleSelectType, 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 ComposeBuildSelect, type ComposeSelect, type ConnectionPolicies, type Constructor, type DataSourceInput, type DataSourceType, type DateColumnOptions, type ExcludeMethods, type ExtractColumnName, type ExtractSourceColumn, type FetchHooks, type GetColumnType, type GetConnectionReturnType, HysteriaError, InMemoryAdapter, type IncrementFields, IncrementMixin, type IndexType, type LazyRelationType, type ManyOptions, type ManyToManyOptions, type ManyToManyStringOptions, Migration, type MigrationConfig, type MigrationConfigBase, type MixinColumns, MixinFactory, Model, type ModelDataProperties, type
|
|
7881
|
+
export { type AbstractConstructor, type AdminJsActionOptions, type AdminJsAssets, type AdminJsBranding, type AdminJsInstance, type AdminJsLocale, type AdminJsOptions, type AdminJsPage, type AdminJsPropertyOptions, type AdminJsResourceOptions, type AdminJsSettings, type AnyConstructor, type AsymmetricEncryptionOptions, type BaseModelMethodOptions, type BaseModelRelationType, BaseSeeder, type BigIntFields, BigIntMixin, type BuildSelectType, type BuildSingleSelectType, 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 ComposeBuildSelect, type ComposeSelect, type ConnectionPolicies, type Constructor, type DataSourceInput, type DataSourceType, type DateColumnOptions, type ExcludeMethods, type ExtractColumnName, type ExtractSourceColumn, type FetchHooks, type FindReturnType, type GetColumnType, type GetConnectionReturnType, HysteriaError, InMemoryAdapter, type IncrementFields, IncrementMixin, type IndexType, type LazyRelationType, type ManyOptions, type ManyToManyOptions, type ManyToManyStringOptions, Migration, type MigrationConfig, type MigrationConfigBase, type MixinColumns, MixinFactory, Model, type ModelDataProperties, type ModelInstanceType, type ModelKey, ModelQueryBuilder, type ModelQueryResult, type ModelRelation, type ModelSelectTuple, type ModelSelectableInput, 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 ReturningColumns, type ReturningKey, Schema, SchemaBuilder, type SeederConfig, type SelectBrand, type 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 SymmetricEncryptionOptions, type TableFormat, type ThroughModel, type TimestampFields, TimestampMixin, Transaction, type TransactionExecutionOptions, type TypedPropertyDecorator, type UlidFields, UlidMixin, type UniqueType, type UseCacheReturnType, type UseConnectionInput, type UuidFields, UuidMixin, WriteOperation, type WriteReturnType, belongsTo, bigIntMixin, column, createMixin, createModelFactory, defineMigrator, generateOpenApiModel, generateOpenApiModelSchema, generateOpenApiModelWithMetadata, getCollectionProperties, getIndexes, getModelColumns, type getPoolReturnType, getPrimaryKey, getRelations, getRelationsMetadata, getUniques, hasMany, hasOne, incrementMixin, index, HysteriaLogger as logger, manyToMany, property, RedisDataSource as redis, timestampMixin, ulidMixin, unique, uuidMixin, view, withPerformance };
|