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

Method SetField

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

5108// the field is not defined in the schema, or if the type mismatched the field
5109// type.
5110func (m *FsEventMutation) SetField(name string, value ent.Value) error {
5111 switch name {
5112 case fsevent.FieldCreatedAt:
5113 v, ok := value.(time.Time)
5114 if !ok {
5115 return fmt.Errorf("unexpected type %T for field %s", value, name)
5116 }
5117 m.SetCreatedAt(v)
5118 return nil
5119 case fsevent.FieldUpdatedAt:
5120 v, ok := value.(time.Time)
5121 if !ok {
5122 return fmt.Errorf("unexpected type %T for field %s", value, name)
5123 }
5124 m.SetUpdatedAt(v)
5125 return nil
5126 case fsevent.FieldDeletedAt:
5127 v, ok := value.(time.Time)
5128 if !ok {
5129 return fmt.Errorf("unexpected type %T for field %s", value, name)
5130 }
5131 m.SetDeletedAt(v)
5132 return nil
5133 case fsevent.FieldEvent:
5134 v, ok := value.(string)
5135 if !ok {
5136 return fmt.Errorf("unexpected type %T for field %s", value, name)
5137 }
5138 m.SetEvent(v)
5139 return nil
5140 case fsevent.FieldSubscriber:
5141 v, ok := value.(uuid.UUID)
5142 if !ok {
5143 return fmt.Errorf("unexpected type %T for field %s", value, name)
5144 }
5145 m.SetSubscriber(v)
5146 return nil
5147 case fsevent.FieldUserFsevent:
5148 v, ok := value.(int)
5149 if !ok {
5150 return fmt.Errorf("unexpected type %T for field %s", value, name)
5151 }
5152 m.SetUserFsevent(v)
5153 return nil
5154 }
5155 return fmt.Errorf("unknown FsEvent field %s", name)
5156}
5157
5158// AddedFields returns all numeric fields that were incremented/decremented during
5159// this mutation.

Callers

nothing calls this directly

Calls 6

SetCreatedAtMethod · 0.95
SetUpdatedAtMethod · 0.95
SetDeletedAtMethod · 0.95
SetEventMethod · 0.95
SetSubscriberMethod · 0.95
SetUserFseventMethod · 0.95

Tested by

no test coverage detected