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

Method SetField

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

7906// the field is not defined in the schema, or if the type mismatched the field
7907// type.
7908func (m *NodeMutation) SetField(name string, value ent.Value) error {
7909 switch name {
7910 case node.FieldCreatedAt:
7911 v, ok := value.(time.Time)
7912 if !ok {
7913 return fmt.Errorf("unexpected type %T for field %s", value, name)
7914 }
7915 m.SetCreatedAt(v)
7916 return nil
7917 case node.FieldUpdatedAt:
7918 v, ok := value.(time.Time)
7919 if !ok {
7920 return fmt.Errorf("unexpected type %T for field %s", value, name)
7921 }
7922 m.SetUpdatedAt(v)
7923 return nil
7924 case node.FieldDeletedAt:
7925 v, ok := value.(time.Time)
7926 if !ok {
7927 return fmt.Errorf("unexpected type %T for field %s", value, name)
7928 }
7929 m.SetDeletedAt(v)
7930 return nil
7931 case node.FieldStatus:
7932 v, ok := value.(node.Status)
7933 if !ok {
7934 return fmt.Errorf("unexpected type %T for field %s", value, name)
7935 }
7936 m.SetStatus(v)
7937 return nil
7938 case node.FieldName:
7939 v, ok := value.(string)
7940 if !ok {
7941 return fmt.Errorf("unexpected type %T for field %s", value, name)
7942 }
7943 m.SetName(v)
7944 return nil
7945 case node.FieldType:
7946 v, ok := value.(node.Type)
7947 if !ok {
7948 return fmt.Errorf("unexpected type %T for field %s", value, name)
7949 }
7950 m.SetType(v)
7951 return nil
7952 case node.FieldServer:
7953 v, ok := value.(string)
7954 if !ok {
7955 return fmt.Errorf("unexpected type %T for field %s", value, name)
7956 }
7957 m.SetServer(v)
7958 return nil
7959 case node.FieldSlaveKey:
7960 v, ok := value.(string)
7961 if !ok {
7962 return fmt.Errorf("unexpected type %T for field %s", value, name)
7963 }
7964 m.SetSlaveKey(v)
7965 return nil

Callers

nothing calls this directly

Calls 11

SetCreatedAtMethod · 0.95
SetUpdatedAtMethod · 0.95
SetDeletedAtMethod · 0.95
SetStatusMethod · 0.95
SetNameMethod · 0.95
SetTypeMethod · 0.95
SetServerMethod · 0.95
SetSlaveKeyMethod · 0.95
SetCapabilitiesMethod · 0.95
SetSettingsMethod · 0.95
SetWeightMethod · 0.95

Tested by

no test coverage detected