`TypeError: value.map is not a function` when performing update all related records
See original GitHub issueBug description
Receive TypeError: value.map is not a function
when performing update all related records.
Related to issue #7085
How to reproduce
export const completeWorkerRequest = async ({ id, comment }) => {
requireAuth({ role: ADMIN_ROLE })
const existing = await db.workerRequest.findUnique({ where: { id } })
return db.workerRequest.update({
where: { id },
data: {
comment,
status: { connect: { id: 0 } },
updatedBy: context.currentUser.email,
actions: {
create: {
actor: context.currentUser.email,
message: 'marked request as completed',
actionType: { connect: { id: 11 } },
},
},
// the following lines causes the above error
workers: {
updateMany: {
data: {
projectId: existing.projectId,
},
},
},
},
})
}
Expected behavior
Able to update all related records with no error.
Prisma information
schema.prisma
other models are omitted for brevity.
datasource DS {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
binaryTargets = "native"
previewFeatures = ["orderByRelation"]
}
model Worker {
id Int @id @default(autoincrement())
name String @unique
employeeNumber String?
socsoNumber String?
mobilePhone String?
remark String?
birthdate DateTime?
arrivalDate DateTime?
isManager WorkerManager? @relation("isManager")
skills Skill[]
permits Permit[]
passports Passport[]
cidbGreenCards CidbGreenCard[]
workerRequests WorkerRequest[]
workerReleases WorkerRelease[]
cidbCompetencies CidbCompetency[]
nationality Country @relation(fields: [nationalityId], references: [id])
nationalityId Int
jobTitle JobTitle @relation(fields: [jobTitleId], references: [id])
jobTitleId Int
project Project? @relation(fields: [projectId], references: [id])
projectId Int?
employer Employer @relation(fields: [employerId], references: [id])
employerId Int
manager WorkerManager @relation(fields: [managerId], references: [id])
managerId Int
status WorkerStatus @relation(fields: [statusId], references: [id])
statusId Int
beneficiary Beneficiary? @relation(fields: [beneficiaryId], references: [id])
beneficiaryId Int?
createdBy String
createdAt DateTime @default(now())
updatedBy String
updatedAt DateTime @updatedAt
}
model WorkerRequest {
id Int @id @default(autoincrement())
startDate DateTime
endDate DateTime?
transferDate DateTime?
description String?
comment String?
jobTitle JobTitle @relation(fields: [jobTitleId], references: [id])
jobTitleId Int
workersQuantity Int
project Project @relation(fields: [projectId], references: [id])
projectId Int
status WorkerRequestStatus @relation(fields: [statusId], references: [id])
statusId Int @default(1)
skills Skill[]
workers Worker[]
actions WorkerRequestAction[]
createdBy String
createdAt DateTime @default(now())
updatedBy String
updatedAt DateTime @updatedAt
links WorkerMovementLink[]
}
Environment & setup
- OS: Windows Subsystem for Linux (Ubuntu-20.04)
- Database: PostgreSQL
- Node.js version: v14.16.1
Prisma Version
prisma : 2.22.1
@prisma/client : 2.22.1
Current platform : debian-openssl-1.1.x
Query Engine : query-engine 60cc71d884972ab4e897f0277c4b84383dddaf6c (at node_modules/@prisma/engines/query-engine-debian-openssl-1.1.x)
Migration Engine : migration-engine-cli 60cc71d884972ab4e897f0277c4b84383dddaf6c (at node_modules/@prisma/engines/migration-engine-debian-openssl-1.1.x)
Introspection Engine : introspection-core 60cc71d884972ab4e897f0277c4b84383dddaf6c (at node_modules/@prisma/engines/introspection-engine-debian-openssl-1.1.x)
Format Binary : prisma-fmt 60cc71d884972ab4e897f0277c4b84383dddaf6c (at node_modules/@prisma/engines/prisma-fmt-debian-openssl-1.1.x)
Default Engines Hash : 60cc71d884972ab4e897f0277c4b84383dddaf6c
Studio : 0.379.0
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
"TypeError: values.map is not a function" error occured when ...
Basically it's saying that you're trying to map over something that is not an Array.. If the code causing the problem is in...
Read more >TypeError: map() is not a function in React | bobbyhadz
The "TypeError: map is not a function" occurs when we call the map() method on a value that is not an array. To...
Read more >How To Fix object.map is not a function Error in JavaScript
To solve the object.map is not a function error, first figure out the shape of the data you are working with and then...
Read more >JavaScript: Uncaught TypeError: n is not a function
This error occurs if you try to execute a function that is not initialized or is not initialized correctly. This means that the...
Read more >How to Prevent the TypeError: Cannot Read Property Map of ...
In the second fetch, there is no country key in the data object, making it undefined . Calling the map function on it...
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
Just got this error today. Saved, thanks to this issue. Can the error thrown by Prisma be better than just
TypeError: value.map is not a function
?Pass an empty
{}
if you don’t want filtering butwhere
is required.