pqb 0.2.5 → 0.2.6
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/dist/index.d.ts +56 -59
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/queryMethods/insert.ts +8 -9
- package/src/queryMethods/update.ts +74 -79
package/dist/index.d.ts
CHANGED
|
@@ -468,7 +468,7 @@ declare type OmitBelongsToForeignKeys<R extends RelationsBase, Data> = Omit<Data
|
|
|
468
468
|
[K in keyof R]: R[K] extends BelongsToRelation ? R[K]['options']['foreignKey'] : never;
|
|
469
469
|
}[keyof R]>;
|
|
470
470
|
declare type InsertRelationData<T extends Query> = {
|
|
471
|
-
[
|
|
471
|
+
[K in keyof T['relations']]: T['relations'][K] extends BelongsToRelation ? InsertBelongsToData<T, K, T['relations'][K]> : T['relations'][K] extends HasOneRelation ? InsertHasOneData<T, K, T['relations'][K]> : T['relations'][K] extends HasManyRelation | HasAndBelongsToManyRelation ? InsertHasManyData<T, K, T['relations'][K]> : EmptyObject;
|
|
472
472
|
}[keyof T['relations']];
|
|
473
473
|
declare type InsertBelongsToData<T extends Query, Key extends keyof T['relations'], Rel extends BelongsToRelation> = SetOptional<{
|
|
474
474
|
[K in Rel['options']['foreignKey']]: Rel['options']['foreignKey'] extends keyof T['inputType'] ? T['inputType'][Rel['options']['foreignKey']] : never;
|
|
@@ -739,64 +739,61 @@ declare class Union {
|
|
|
739
739
|
declare type UpdateData<T extends Query> = {
|
|
740
740
|
[K in keyof T['type']]?: T['type'][K] | RawExpression;
|
|
741
741
|
} & (T['relations'] extends Record<string, Relation> ? {
|
|
742
|
-
[K in keyof T['relations']]?: T['relations'][K]['
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
create: InsertData<
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
create: InsertData<T['relations'][K]['nestedCreateQuery']>[];
|
|
798
|
-
} : never;
|
|
799
|
-
} : {});
|
|
742
|
+
[K in keyof T['relations']]?: T['relations'][K] extends BelongsToRelation ? UpdateBelongsToData<T, T['relations'][K]> : T['relations'][K] extends HasOneRelation ? UpdateHasOneData<T, T['relations'][K]> : T['relations'][K] extends HasManyRelation ? UpdateHasManyData<T, T['relations'][K]> : T['relations'][K] extends HasAndBelongsToManyRelation ? UpdateHasAndBelongsToManyData<T['relations'][K]> : never;
|
|
743
|
+
} : EmptyObject);
|
|
744
|
+
declare type UpdateBelongsToData<T extends Query, Rel extends BelongsToRelation> = {
|
|
745
|
+
disconnect: boolean;
|
|
746
|
+
} | {
|
|
747
|
+
set: WhereArg<Rel['model']>;
|
|
748
|
+
} | {
|
|
749
|
+
delete: boolean;
|
|
750
|
+
} | {
|
|
751
|
+
update: UpdateData<Rel['model']>;
|
|
752
|
+
} | {
|
|
753
|
+
create: InsertData<Rel['nestedCreateQuery']>;
|
|
754
|
+
} | (T['returnType'] extends 'one' | 'oneOrThrow' ? {
|
|
755
|
+
upsert: {
|
|
756
|
+
update: UpdateData<Rel['model']>;
|
|
757
|
+
create: InsertData<Rel['nestedCreateQuery']>;
|
|
758
|
+
};
|
|
759
|
+
} : never);
|
|
760
|
+
declare type UpdateHasOneData<T extends Query, Rel extends HasOneRelation> = {
|
|
761
|
+
disconnect: boolean;
|
|
762
|
+
} | {
|
|
763
|
+
delete: boolean;
|
|
764
|
+
} | {
|
|
765
|
+
update: UpdateData<Rel['model']>;
|
|
766
|
+
} | (T['returnType'] extends 'one' | 'oneOrThrow' ? {
|
|
767
|
+
set: WhereArg<Rel['model']>;
|
|
768
|
+
} | {
|
|
769
|
+
upsert: {
|
|
770
|
+
update: UpdateData<Rel['model']>;
|
|
771
|
+
create: InsertData<Rel['nestedCreateQuery']>;
|
|
772
|
+
};
|
|
773
|
+
} | {
|
|
774
|
+
create: InsertData<Rel['nestedCreateQuery']>;
|
|
775
|
+
} : never);
|
|
776
|
+
declare type UpdateHasManyData<T extends Query, Rel extends HasManyRelation> = {
|
|
777
|
+
disconnect?: MaybeArray<WhereArg<Rel['model']>>;
|
|
778
|
+
delete?: MaybeArray<WhereArg<Rel['model']>>;
|
|
779
|
+
update?: {
|
|
780
|
+
where: MaybeArray<WhereArg<Rel['model']>>;
|
|
781
|
+
data: UpdateData<Rel['model']>;
|
|
782
|
+
};
|
|
783
|
+
} & (T['returnType'] extends 'one' | 'oneOrThrow' ? {
|
|
784
|
+
set?: MaybeArray<WhereArg<Rel['model']>>;
|
|
785
|
+
create?: InsertData<Rel['nestedCreateQuery']>[];
|
|
786
|
+
} : EmptyObject);
|
|
787
|
+
declare type UpdateHasAndBelongsToManyData<Rel extends HasAndBelongsToManyRelation> = {
|
|
788
|
+
disconnect?: MaybeArray<WhereArg<Rel['model']>>;
|
|
789
|
+
set?: MaybeArray<WhereArg<Rel['model']>>;
|
|
790
|
+
delete?: MaybeArray<WhereArg<Rel['model']>>;
|
|
791
|
+
update?: {
|
|
792
|
+
where: MaybeArray<WhereArg<Rel['model']>>;
|
|
793
|
+
data: UpdateData<Rel['model']>;
|
|
794
|
+
};
|
|
795
|
+
create?: InsertData<Rel['nestedCreateQuery']>[];
|
|
796
|
+
};
|
|
800
797
|
declare type UpdateArgs<T extends Query, ForceAll extends boolean> = (T['hasWhere'] extends true ? true : ForceAll) extends true ? [update: RawExpression | UpdateData<T>, forceAll?: ForceAll] : [update: RawExpression | UpdateData<T>, forceAll: true];
|
|
801
798
|
declare type UpdateResult<T extends Query> = T['hasSelect'] extends false ? SetQueryReturnsRowCount<T> : T;
|
|
802
799
|
declare type ChangeCountArg<T extends Query> = keyof T['shape'] | Partial<Record<keyof T['shape'], number>>;
|