UpdateUserMetaData sets all user data from a map of updates, ensuring that it doesn't override attributes that are not in the provided map.
(tx *storage.Connection, updates map[string]interface{})
| 226 | // ensuring that it doesn't override attributes that are not |
| 227 | // in the provided map. |
| 228 | func (u *User) UpdateUserMetaData(tx *storage.Connection, updates map[string]interface{}) error { |
| 229 | if u.UserMetaData == nil { |
| 230 | u.UserMetaData = updates |
| 231 | } else { |
| 232 | for key, value := range updates { |
| 233 | if value != nil { |
| 234 | u.UserMetaData[key] = value |
| 235 | } else { |
| 236 | delete(u.UserMetaData, key) |
| 237 | } |
| 238 | } |
| 239 | } |
| 240 | return tx.UpdateOnly(u, "raw_user_meta_data") |
| 241 | } |
| 242 | |
| 243 | // UpdateAppMetaData updates all app data from a map of updates |
| 244 | func (u *User) UpdateAppMetaData(tx *storage.Connection, updates map[string]interface{}) error { |