-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add upsert methods for the drivers that support onUpdate #8104
Changes from 4 commits
5f37460
3c0a5d9
9703549
343d0f0
c31d0e1
c30408d
9e4f50f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export type UpsertType = "on-conflict-do-update" | "on-duplicate-key-update"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { PropertyPath } from "../util/PropertyPath"; | ||
|
||
/** | ||
* Special options passed to Repository#upsert | ||
*/ | ||
export interface UpsertOptions<Entity> { | ||
conflictPaths: PropertyPath<Entity>[] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
export type MaxPropertyPathRecursionDepth = 5; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is going to be a breaking change for users since we support TypeScript versions far behind There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh, didn't realize pre-4 was still supported :( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah 0.2.x is quite old and we are trying to avoid breaking changes. I hope when we finally release There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let me know if I can be of assistance with |
||
|
||
export type PropertyPath<T> = PropertyPathInner<T, keyof T, MaxPropertyPathRecursionDepth, []>; | ||
|
||
type PropertyPathInner< | ||
T, | ||
Key, | ||
MaxDepth extends number, | ||
AccumulatedDepth extends unknown[] | ||
> = Key extends keyof T & string ? | ||
Exclude<T[Key], null | undefined> extends Function ? never : Exclude<T[Key], null | undefined> extends string | symbol | number | Date ? Key : Key | | ||
(AccumulatedDepth["length"] extends MaxDepth ? never : `${Key}.${PropertyPathInner< | ||
Exclude<T[Key], null | undefined>, | ||
keyof (Exclude<T[Key], null | undefined>), | ||
MaxDepth, | ||
[unknown, ...AccumulatedDepth] | ||
>}`) : never; | ||
|
||
export type MaxRelationPathRecursionDepth = 5; | ||
|
||
export type RelationPath<T> = RelationPathInner<T, keyof T, MaxRelationPathRecursionDepth, []>; | ||
|
||
type RelationPathInner< | ||
T, | ||
Key, | ||
MaxDepth extends number, | ||
AccumulatedDepth extends unknown[] | ||
> = Key extends keyof T & string ? | ||
Exclude<T[Key], null | undefined> extends Function ? never : Exclude<T[Key], null | undefined> extends string | symbol | number | Date ? Key : Key | | ||
(AccumulatedDepth["length"] extends MaxDepth ? never : `${Key}.${RelationPathInner< | ||
Exclude<T[Key], null | undefined> extends (infer R)[] ? R : T[Key], | ||
keyof (Exclude<T[Key], null | undefined> extends (infer R)[] ? R : T[Key]), | ||
MaxDepth, | ||
[unknown, ...AccumulatedDepth] | ||
>}`) : never; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also need to specify list of supported drivers here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
incoming