Assuming the first_name key is always present in the request body: which is more optimum , method 1 or method 2 ?
const user: any = {}
// Use ternary operator - 1
user.first_name = req.body.first_name ? req.body.first_name : user.first_name
//Or Spread operator with && - 2
user = {
...(req.body.first_name && {'first_name': req.body.first_name} )
}
user.save()