MCPcopy
hub / github.com/Wei-Shaw/sub2api / SetField

Method SetField

backend/ent/mutation.go:41299–41464  ·  view source on GitHub ↗

SetField sets the value of a field with the given name. It returns an error if the field is not defined in the schema, or if the type mismatched the field type.

(name string, value ent.Value)

Source from the content-addressed store, hash-verified

41297// the field is not defined in the schema, or if the type mismatched the field
41298// type.
41299func (m *UserMutation) SetField(name string, value ent.Value) error {
41300 switch name {
41301 case user.FieldCreatedAt:
41302 v, ok := value.(time.Time)
41303 if !ok {
41304 return fmt.Errorf("unexpected type %T for field %s", value, name)
41305 }
41306 m.SetCreatedAt(v)
41307 return nil
41308 case user.FieldUpdatedAt:
41309 v, ok := value.(time.Time)
41310 if !ok {
41311 return fmt.Errorf("unexpected type %T for field %s", value, name)
41312 }
41313 m.SetUpdatedAt(v)
41314 return nil
41315 case user.FieldDeletedAt:
41316 v, ok := value.(time.Time)
41317 if !ok {
41318 return fmt.Errorf("unexpected type %T for field %s", value, name)
41319 }
41320 m.SetDeletedAt(v)
41321 return nil
41322 case user.FieldEmail:
41323 v, ok := value.(string)
41324 if !ok {
41325 return fmt.Errorf("unexpected type %T for field %s", value, name)
41326 }
41327 m.SetEmail(v)
41328 return nil
41329 case user.FieldPasswordHash:
41330 v, ok := value.(string)
41331 if !ok {
41332 return fmt.Errorf("unexpected type %T for field %s", value, name)
41333 }
41334 m.SetPasswordHash(v)
41335 return nil
41336 case user.FieldRole:
41337 v, ok := value.(string)
41338 if !ok {
41339 return fmt.Errorf("unexpected type %T for field %s", value, name)
41340 }
41341 m.SetRole(v)
41342 return nil
41343 case user.FieldBalance:
41344 v, ok := value.(float64)
41345 if !ok {
41346 return fmt.Errorf("unexpected type %T for field %s", value, name)
41347 }
41348 m.SetBalance(v)
41349 return nil
41350 case user.FieldConcurrency:
41351 v, ok := value.(int)
41352 if !ok {
41353 return fmt.Errorf("unexpected type %T for field %s", value, name)
41354 }
41355 m.SetConcurrency(v)
41356 return nil

Callers 15

sqlSaveMethod · 0.45
sqlSaveMethod · 0.45
sqlSaveMethod · 0.45
sqlSaveMethod · 0.45
sqlSaveMethod · 0.45
sqlSaveMethod · 0.45
createSpecMethod · 0.45
sqlSaveMethod · 0.45
sqlSaveMethod · 0.45
createSpecMethod · 0.45
sqlSaveMethod · 0.45
sqlSaveMethod · 0.45

Calls 15

SetCreatedAtMethod · 0.95
SetUpdatedAtMethod · 0.95
SetDeletedAtMethod · 0.95
SetEmailMethod · 0.95
SetPasswordHashMethod · 0.95
SetRoleMethod · 0.95
SetBalanceMethod · 0.95
SetConcurrencyMethod · 0.95
SetStatusMethod · 0.95
SetUsernameMethod · 0.95
SetNotesMethod · 0.95

Tested by

no test coverage detected