Skip to content
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

Add upsertMany CRUD operation #5066

Closed
tomdohnal opened this issue Aug 15, 2020 · 3 comments
Closed

Add upsertMany CRUD operation #5066

tomdohnal opened this issue Aug 15, 2020 · 3 comments
Labels
kind/feature A request for a new feature. team/client Issue for team Client. topic: upsert()

Comments

@tomdohnal
Copy link

Problem

I want to upsert a large number of items to the DB efficiently and I'd like to use a prisma.myModel.upsertMany(...) method.

Suggested solution

The upsertMany method would batch-upsert an array of models into the DB.

Alternatives

An alternative I came up with is using something like this:

const requests = items.map(item => prisma.myModel.upsert(item))

await prisma.$transaction(requests)
@pantharshit00 pantharshit00 transferred this issue from prisma/prisma Aug 17, 2020
@pantharshit00 pantharshit00 transferred this issue from prisma/prisma-client-js Jan 13, 2021
@pantharshit00 pantharshit00 added kind/feature A request for a new feature. team/client Issue for team Client. labels Jan 13, 2021
@pantharshit00
Copy link
Contributor

Closing in favour of #4134

@goleary
Copy link

goleary commented Oct 14, 2021

@pantharshit00 curious why you closed this request?

If I'm not mistaken the functionality described in #4134 is different than what's requested here.

#4134 describes updating many records (or the first) using the same data, but what I'd expect upsertMany to do is update many records, all with (potentially) different data.

Perhaps the name of that issue should be changed & this one reopened?

Or the description of the other one updated to reflect what upsertMany could reasonably be expected to do?

@pantharshit00
Copy link
Contributor

I would suggest you to comment on #4134 about this functionality.

There is no final proposal for upsertMany yet so having multiple feature request about the similar thing describing it would just increase the issue count of the repository. If updateMany already existed and it was well defined, then I would have kept this open.

We could have data an array to include the above usecase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature A request for a new feature. team/client Issue for team Client. topic: upsert()
Projects
None yet
Development

No branches or pull requests

6 participants