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

Method AddField

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

2737// the field is not defined in the schema, or if the type mismatched the field
2738// type.
2739func (m *EntityMutation) AddField(name string, value ent.Value) error {
2740 switch name {
2741 case entity.FieldType:
2742 v, ok := value.(int)
2743 if !ok {
2744 return fmt.Errorf("unexpected type %T for field %s", value, name)
2745 }
2746 m.AddType(v)
2747 return nil
2748 case entity.FieldSize:
2749 v, ok := value.(int64)
2750 if !ok {
2751 return fmt.Errorf("unexpected type %T for field %s", value, name)
2752 }
2753 m.AddSize(v)
2754 return nil
2755 case entity.FieldReferenceCount:
2756 v, ok := value.(int)
2757 if !ok {
2758 return fmt.Errorf("unexpected type %T for field %s", value, name)
2759 }
2760 m.AddReferenceCount(v)
2761 return nil
2762 }
2763 return fmt.Errorf("unknown Entity numeric field %s", name)
2764}
2765
2766// ClearedFields returns all nullable fields that were cleared during this
2767// mutation.

Callers

nothing calls this directly

Calls 3

AddTypeMethod · 0.95
AddSizeMethod · 0.95
AddReferenceCountMethod · 0.95

Tested by

no test coverage detected