MCPcopy
hub / github.com/crowdsecurity/crowdsec / SetField

Method SetField

pkg/database/ent/mutation.go:8623–8641  ·  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

8621// the field is not defined in the schema, or if the type mismatched the field
8622// type.
8623func (m *LockMutation) SetField(name string, value ent.Value) error {
8624 switch name {
8625 case lock.FieldName:
8626 v, ok := value.(string)
8627 if !ok {
8628 return fmt.Errorf("unexpected type %T for field %s", value, name)
8629 }
8630 m.SetName(v)
8631 return nil
8632 case lock.FieldCreatedAt:
8633 v, ok := value.(time.Time)
8634 if !ok {
8635 return fmt.Errorf("unexpected type %T for field %s", value, name)
8636 }
8637 m.SetCreatedAt(v)
8638 return nil
8639 }
8640 return fmt.Errorf("unknown Lock field %s", name)
8641}
8642
8643// AddedFields returns all numeric fields that were incremented/decremented during
8644// this mutation.

Callers 15

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

Calls 2

SetNameMethod · 0.95
SetCreatedAtMethod · 0.95

Tested by

no test coverage detected