code to update :
return db.models.sprout.update({
first_name: args.input.patch.first_name,
last_name: args.input.patch.last_name,
date_of_birth: args.input.patch.date_of_birth,
image_url: args.input.patch.image_url,
updated_by: args.input.user_id
},{ where: { sprout_id : args.input.sprout_id }}).then((rowsUpdated) => {
none of the fields have not null constraint in table.
this should ideally update only, values which are provided, in the args.input.patch i provided only image_url
i get this error.
notNull Violation: sprout.first_name cannot be null,\nnotNull Violation: sprout.last_name cannot be null
weird, the insert works the way i want, only inserts whichever is present
return db.models.sprout.create({
sprout_id: uuidv4(),
first_name: args.input.sprout.first_name,
last_name: args.input.sprout.last_name,
date_of_birth: args.input.sprout.date_of_birth,
image_url: args.input.sprout.image_url,
created_by: args.input.user_id
})
if i dont give image_url or any other field , insert works fine, and ignore the null, but the update doesn't .
How can i make update to ignore the null values.