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

Method AddField

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

12303// the field is not defined in the schema, or if the type mismatched the field
12304// type.
12305func (m *ShareMutation) AddField(name string, value ent.Value) error {
12306 switch name {
12307 case share.FieldViews:
12308 v, ok := value.(int)
12309 if !ok {
12310 return fmt.Errorf("unexpected type %T for field %s", value, name)
12311 }
12312 m.AddViews(v)
12313 return nil
12314 case share.FieldDownloads:
12315 v, ok := value.(int)
12316 if !ok {
12317 return fmt.Errorf("unexpected type %T for field %s", value, name)
12318 }
12319 m.AddDownloads(v)
12320 return nil
12321 case share.FieldRemainDownloads:
12322 v, ok := value.(int)
12323 if !ok {
12324 return fmt.Errorf("unexpected type %T for field %s", value, name)
12325 }
12326 m.AddRemainDownloads(v)
12327 return nil
12328 }
12329 return fmt.Errorf("unknown Share numeric field %s", name)
12330}
12331
12332// ClearedFields returns all nullable fields that were cleared during this
12333// mutation.

Callers

nothing calls this directly

Calls 3

AddViewsMethod · 0.95
AddDownloadsMethod · 0.95
AddRemainDownloadsMethod · 0.95

Tested by

no test coverage detected