Check out example codes for "gorm update". It will help you in understanding the concepts better.

Code Example 1

// Update single attribute if it is changeddb.Model(&user).Update("name", "hello")//// UPDATE users SET name='hello', updated_at='2013-11-17 21:34:10' WHERE id=111;// Update single attribute with combined conditionsdb.Model(&user).Where("active = ?", true).Update("name", "hello")//// UPDATE users SET name='hello', updated_at='2013-11-17 21:34:10' WHERE id=111 AND active=true;// Update multiple attributes with `map`, will only update those changed fieldsdb.Model(&user).Updates(map[string]interface{}{"name": "hello", "age": 18, "actived": false})//// UPDATE users SET name='hello', age=18, actived=false, updated_at='2013-11-17 21:34:10' WHERE id=111;// Update multiple attributes with `struct`, will only update those changed & non blank fieldsdb.Model(&user).Updates(User{Name: "hello", Age: 18})//// UPDATE users SET name='hello', age=18, updated_at = '2013-11-17 21:34:10' WHERE id = 111;// WARNING when update with struct, GORM will only update those fields that with non blank value// For below Update, nothing will be updated as "", 0, false are blank values of their typesdb.Model(&user).Updates(User{Name: "", Age: 0, Actived: false})

Learn ReactJs, React Native from akashmittal.com