jacob
jacob
PPrisma
Created by jacob on 4/29/2025 in #help-and-questions
Prisma migrate deploy only first N migrations
Is there a way to run prisma migrate deploy for only first n migrations?
3 replies
PPrisma
Created by jacob on 4/29/2025 in #help-and-questions
Spreading data object with foreing keys in update() does not allow unchecked input
Basically the title summarizes my problem. We have a model that has category relation so it has categoryId as a foreign key. We handle type safety and validation using typebox and then spread the input object in update's data object. Like this:
await prisma.product.update({
where: {
...
},
data: {
...input
}
})
await prisma.product.update({
where: {
...
},
data: {
...input
}
})
Input contains flat parameters like strings and numbers and those get updated correctly but when we supply categoryId we get the following error:
Unknown argument `categoryId`. Did you mean `category`?
Unknown argument `categoryId`. Did you mean `category`?
The workaround was that we destruct the input and manually enter the categoryId and then spread the rest like this:
const { categoryId, ...rest } = input
await prisma.product.update({
where: {
...
},
data: {
...rest,
categoryId
}
})
const { categoryId, ...rest } = input
await prisma.product.update({
where: {
...
},
data: {
...rest,
categoryId
}
})
Why is this necessary? Why can't we just spread the whole object? Prisma just automatically expects the "not unchecked" input.
4 replies