MCPcopy Create free account
hub / github.com/cloudreve/cloudreve / SetField

Method SetField

ent/mutation.go:11258–11297  ·  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

11256// the field is not defined in the schema, or if the type mismatched the field
11257// type.
11258func (m *SettingMutation) SetField(name string, value ent.Value) error {
11259 switch name {
11260 case setting.FieldCreatedAt:
11261 v, ok := value.(time.Time)
11262 if !ok {
11263 return fmt.Errorf("unexpected type %T for field %s", value, name)
11264 }
11265 m.SetCreatedAt(v)
11266 return nil
11267 case setting.FieldUpdatedAt:
11268 v, ok := value.(time.Time)
11269 if !ok {
11270 return fmt.Errorf("unexpected type %T for field %s", value, name)
11271 }
11272 m.SetUpdatedAt(v)
11273 return nil
11274 case setting.FieldDeletedAt:
11275 v, ok := value.(time.Time)
11276 if !ok {
11277 return fmt.Errorf("unexpected type %T for field %s", value, name)
11278 }
11279 m.SetDeletedAt(v)
11280 return nil
11281 case setting.FieldName:
11282 v, ok := value.(string)
11283 if !ok {
11284 return fmt.Errorf("unexpected type %T for field %s", value, name)
11285 }
11286 m.SetName(v)
11287 return nil
11288 case setting.FieldValue:
11289 v, ok := value.(string)
11290 if !ok {
11291 return fmt.Errorf("unexpected type %T for field %s", value, name)
11292 }
11293 m.SetValue(v)
11294 return nil
11295 }
11296 return fmt.Errorf("unknown Setting field %s", name)
11297}
11298
11299// AddedFields returns all numeric fields that were incremented/decremented during
11300// this mutation.

Callers

nothing calls this directly

Calls 5

SetCreatedAtMethod · 0.95
SetUpdatedAtMethod · 0.95
SetDeletedAtMethod · 0.95
SetNameMethod · 0.95
SetValueMethod · 0.95

Tested by

no test coverage detected