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

Method AddField

ent/mutation.go:8015–8026  ·  view source on GitHub ↗

AddField adds the value to the 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

8013// the field is not defined in the schema, or if the type mismatched the field
8014// type.
8015func (m *NodeMutation) AddField(name string, value ent.Value) error {
8016 switch name {
8017 case node.FieldWeight:
8018 v, ok := value.(int)
8019 if !ok {
8020 return fmt.Errorf("unexpected type %T for field %s", value, name)
8021 }
8022 m.AddWeight(v)
8023 return nil
8024 }
8025 return fmt.Errorf("unknown Node numeric field %s", name)
8026}
8027
8028// ClearedFields returns all nullable fields that were cleared during this
8029// mutation.

Callers

nothing calls this directly

Calls 1

AddWeightMethod · 0.95

Tested by

no test coverage detected