trick to handle potentially undefined values

In my user table age is optional So my code looks like
await ctx.prisma.user.create({
data:{
username: input.username,
name: input.name,
age: input.age length > 0 ? input.age : null
}})
await ctx.prisma.user.create({
data:{
username: input.username,
name: input.name,
age: input.age length > 0 ? input.age : null
}})
This works fine before but all of a sudden it stopped work Any tricks So basically i want prisma to ignore nullable fields despite it been provided from it the front-end as long as its empty should be set as null
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server