Provide `upsertMany`/ `upsertFirst` operation in the client API
See original GitHub issueProblem
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
Add a CRUD query upsertMany
. If the where clause finds at least one row, then an update is performed, else, a create is performed.
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
orinclude
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
Issue Analytics
- State:
- Created 3 years ago
- Reactions:225
- Comments:26
Top Results From Across the Web
createEntityAdapter
A function that generates a set of prebuilt reducers and selectors for performing CRUD operations on a normalized state structure containing ...
Read more >ふむ。prismaはupsertManyみたいなのはまだないぽい
ふむ。prismaはupsertManyみたいなのはまだないぽい. Превод на туита. github.com. Provide `upsertMany`/ `upsertFirst` operation in the client API · Issue #4134 ...
Read more >CRUD (Reference)
This page describes how to perform CRUD operations with your generated Prisma Client API. CRUD is an acronym that stands for: Create; Read;...
Read more >Untitled
Learn how to use python api pymongo. Unordered bulk write operations are batched and sent to the server in arbitrary order where they...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I would suggest that
upsertMany
should be reserved for a function that can bulk upsert multiple rows at once so the name of this operation should probably be something likeupsertFirst
.Currently using sql instead