Prisma Client upsert returns count instead of data
See original GitHub issueBug description
When using the upsert
method to do a findOrCreate
implementation, count: { 1 }
is returned rather than the data itself.
How to reproduce
Using the following code returns count
rather than the user
object
const user = await prisma.user.upsert({
where: { email: emails[0].value },
update: { lastLoggedIn: new Date() },
create: {
email: emails[0].value,
name: displayName,
avi: photos[0].value,
profile: {
create: {
name: displayName,
avi: photos[0].value,
email: emails[0].value,
},
},
},
});
console.log({ user });
Expected behavior
I expect the user’s data to be returned.
Prisma information
model User {
id String @id @default(uuid())
email String @unique
name String
avi String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
lastLoggedIn DateTime @default(now())
log Log[]
items Item[]
rsvps Rsvp[] @relation("rsvp_user")
createdEvents Event[] @relation(name: "created_event")
profile Profile? @relation("profile_user")
}
Environment & setup
- OS: Mac OS
- Database: MySQL
- Node.js version: v14.17.3
Prisma Version
prisma : 3.6.0
@prisma/client : 3.7.0
Issue Analytics
- State:
- Created 2 years ago
- Reactions:5
- Comments:37 (15 by maintainers)
Top Results From Across the Web
update() returning { count: 1 } · Issue #5852 · prisma ... - GitHub
What happens if you run this Prisma Client query outside of a resolver in the same project? Do you still see the error?...
Read more >Aggregation, grouping, and summarizing (Concepts) - Prisma
Aggregation, grouping, and summarizing. Prisma Client allows you to count records, aggregate number fields, and select distinct field values.
Read more >Prisma Client API (Reference)
Prisma Client uses a database upsert for an upsert query when the query meets the following criteria: There are no nested queries in...
Read more >CRUD (Reference) - Prisma
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 >Relation queries (Concepts) - Prisma
When you use select to return a subset of data from related records (for example, a user's posts), you can filter and sort...
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
yup!
Yes