orchid-orm 1.3.15 → 1.3.16

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # orchid-orm
2
2
 
3
+ ## 1.3.16
4
+
5
+ ### Patch Changes
6
+
7
+ - Refactor create and update of relations
8
+ - Updated dependencies
9
+ - pqb@0.7.13
10
+
3
11
  ## 1.3.15
4
12
 
5
13
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { BelongsToRelation, HasOneRelation, Db, Adapter, AdapterOptions, QueryLogOptions, NoPrimaryKeyOption, HasManyRelation, HasAndBelongsToManyRelation, Query, defaultsKey, BaseRelation, EmptyObject, RelationQuery, SetQueryReturnsOne, SetQueryReturnsOneOptional, SetQueryReturnsAll, ColumnTypesBase, ColumnsShape, ColumnShapeOutput, WhereResult, MergeQuery, SetQueryReturns, QueryReturnType } from 'pqb';
1
+ import { BelongsToRelation, HasManyRelation, HasOneRelation, Db, Adapter, AdapterOptions, QueryLogOptions, NoPrimaryKeyOption, HasAndBelongsToManyRelation, Query, defaultsKey, EmptyObject, BaseRelation, RelationQuery, SetQueryReturnsOne, SetQueryReturnsOneOptional, SetQueryReturnsAll, ColumnTypesBase, ColumnsShape, ColumnShapeOutput, WhereResult, MergeQuery, SetQueryReturns, QueryReturnType } from 'pqb';
2
2
 
3
3
  interface BelongsTo extends RelationThunkBase {
4
4
  type: 'belongsTo';
@@ -12,6 +12,26 @@ declare type BelongsToInfo<T extends Model, Relation extends BelongsTo, FK exten
12
12
  chainedDelete: false;
13
13
  };
14
14
 
15
+ interface HasMany extends RelationThunkBase {
16
+ type: 'hasMany';
17
+ returns: 'many';
18
+ options: HasManyRelation['options'];
19
+ }
20
+ declare type HasManyInfo<T extends Model, Relations extends RelationThunks, Relation extends HasMany> = {
21
+ params: Relation['options'] extends {
22
+ primaryKey: string;
23
+ } ? Record<Relation['options']['primaryKey'], T['columns']['shape'][Relation['options']['primaryKey']]['type']> : Relation['options'] extends {
24
+ through: string;
25
+ } ? RelationInfo<T, Relations, Relations[Relation['options']['through']]>['params'] : never;
26
+ populate: Relation['options'] extends {
27
+ foreignKey: string;
28
+ } ? Relation['options']['foreignKey'] : never;
29
+ chainedCreate: Relation['options'] extends {
30
+ primaryKey: string;
31
+ } ? true : false;
32
+ chainedDelete: true;
33
+ };
34
+
15
35
  interface HasOne extends RelationThunkBase {
16
36
  type: 'hasOne';
17
37
  returns: 'one';
@@ -51,26 +71,6 @@ declare const orchidORM: <T extends ModelClasses>({ log, logger, autoPreparedSta
51
71
  noPrimaryKey?: NoPrimaryKeyOption | undefined;
52
72
  }, models: T) => OrchidORM<T>;
53
73
 
54
- interface HasMany extends RelationThunkBase {
55
- type: 'hasMany';
56
- returns: 'many';
57
- options: HasManyRelation['options'];
58
- }
59
- declare type HasManyInfo<T extends Model, Relations extends RelationThunks, Relation extends HasMany> = {
60
- params: Relation['options'] extends {
61
- primaryKey: string;
62
- } ? Record<Relation['options']['primaryKey'], T['columns']['shape'][Relation['options']['primaryKey']]['type']> : Relation['options'] extends {
63
- through: string;
64
- } ? RelationInfo<T, Relations, Relations[Relation['options']['through']]>['params'] : never;
65
- populate: Relation['options'] extends {
66
- foreignKey: string;
67
- } ? Relation['options']['foreignKey'] : never;
68
- chainedCreate: Relation['options'] extends {
69
- primaryKey: string;
70
- } ? true : false;
71
- chainedDelete: true;
72
- };
73
-
74
74
  interface HasAndBelongsToMany extends RelationThunkBase {
75
75
  type: 'hasAndBelongsToMany';
76
76
  returns: 'many';
@@ -102,8 +102,6 @@ declare type Relation<T extends Model, Relations extends RelationThunks, K exten
102
102
  nestedCreateQuery: [Info['populate']] extends [never] ? M : M & {
103
103
  [defaultsKey]: Record<Info['populate'], true>;
104
104
  };
105
- nestedInsert: BaseRelation['nestedInsert'];
106
- nestedUpdate: BaseRelation['nestedUpdate'];
107
105
  primaryKey: string;
108
106
  options: Relations[K]['options'];
109
107
  };