Shivam Singh
05/18/2022, 1:10 PMawait this.prismaService.person.update({
where: {
id,
},
data: {
name,
configuration: {
update: configuration,
},
address,
age,
}
})
Now name, address and age comes from request body and might be empty. I want to update these properties only if they are not empty. Is there a way to do so?Ruben Amendoeira
05/18/2022, 2:34 PMconst updateInput: PersonUpdateInput = {
configuration: {
update: configuration
}
};
if(age && age.length > 0) updateInput.age = age;
if(name && name.length > 0) updateInput.name = name;
if(address && address.length > 0) updateInput.address = address;
await this.prismaService.person.update({
where: { id },
data: updateInput
})Ruben Amendoeira
05/18/2022, 2:35 PMPersonUpdateInput from the prisma types,
as prisma.person.update will receive PersonUpdateArgs , which should include:
data: _XOR_<_PersonUpdateInput_, _PersonUncheckedUpdateInput_>Nurul
05/25/2022, 11:38 AM