Provide `upsertMany()`/`upsertFirst()` operation in the client API
## Problem <!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] --> I'm frustrated when I want to do an upsert of a specific row, but I don't have fields that are in `<Model>WhereUniqueInput` - I only have fields that, according to my business logic, will find a unique row. Currently, I have to do a findFirst to find the ID of the row, then either a create if it doesn't exist or an update if it does. ## Suggested solution <!-- A clear and concise description of what you want to happen. --> Add a CRUD query `upsertMany`. If the where clause finds at least one row, then an update is performed, else, a create is performed. ```ts export type UserUpsertManyArgs = { select?: UserSelect | null include?: UserInclude | null where?: UserWhereInput | null create: UserCreateInput update: UserUpdateInput } ``` I'm not sure what it should return, some possibilities are: * the number of updated objects (probably 0 if a create is done); in which case don't have the `select` or `include` parameters * a list of the updated objects, or the object itself if a create is done * the number of updated objects, or the object itself if a create is done
Posted by olliechick on Nov 2, 2020, 10:34 PM
Tags
Related issues
- struct's lifetime requirements can be bypassed via covariant field assignment
- Proposal to Reorganize the Moderation Team and Review Moderation Policies
- Progressive FPS degradation appears to be related to dota2.com — blocking the domain prevents the performance loss
- proposal: container/...: generic collection types
- Better Custom Endpoint BYOK
- A concrete policy for backward compatibility until Godot 5.0
Raise real-world problems, find people facing the same issue, and discuss solutions.3,000 issues0 comments
github (Other)
struct's lifetime requirements can be bypassed via covariant field assignment
Proposal to Reorganize the Moderation Team and Review Moderation Policies
Progressive FPS degradation appears to be related to dota2.com — blocking the domain prevents the performance loss
proposal: container/...: generic collection types
Better Custom Endpoint BYOK
A concrete policy for backward compatibility until Godot 5.0
New MTP models not supported
Tracking: 429 / Capacity Issues
Provide `upsertMany()`/`upsertFirst()` operation in the client API
## Problem <!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] --> I'm frustrated when I want to do an upsert of a specific row, but I don't have fields that are in `<Model>WhereUniqueInput` - I only have fields that, according to my business logic, will find a unique row. Currently, I have to do a findFirst to find the ID of the row, then either a create if it doesn't exist or an update if it does. ## Suggested solution <!-- A clear and concise description of what you want to happen. --> Add a CRUD query `upsertMany`. If the where clause finds at least one row, then an update is performed, else, a create is performed. ```ts export type UserUpsertManyArgs = { select?: UserSelect | null include?: UserInclude | null where?: UserWhereInput | null create: UserCreateInput update: UserUpdateInput } ``` I'm not sure what it should return, some possibilities are: * the number of updated objects (probably 0 if a create is done); in which case don't have the `select` or `include` parameters * a list of the updated objects, or the object itself if a create is done * the number of updated objects, or the object itself if a create is done
Comments (0)
No comments yet. Start the discussion.