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

Method SetField

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

13702// the field is not defined in the schema, or if the type mismatched the field
13703// type.
13704func (m *StoragePolicyMutation) SetField(name string, value ent.Value) error {
13705 switch name {
13706 case storagepolicy.FieldCreatedAt:
13707 v, ok := value.(time.Time)
13708 if !ok {
13709 return fmt.Errorf("unexpected type %T for field %s", value, name)
13710 }
13711 m.SetCreatedAt(v)
13712 return nil
13713 case storagepolicy.FieldUpdatedAt:
13714 v, ok := value.(time.Time)
13715 if !ok {
13716 return fmt.Errorf("unexpected type %T for field %s", value, name)
13717 }
13718 m.SetUpdatedAt(v)
13719 return nil
13720 case storagepolicy.FieldDeletedAt:
13721 v, ok := value.(time.Time)
13722 if !ok {
13723 return fmt.Errorf("unexpected type %T for field %s", value, name)
13724 }
13725 m.SetDeletedAt(v)
13726 return nil
13727 case storagepolicy.FieldName:
13728 v, ok := value.(string)
13729 if !ok {
13730 return fmt.Errorf("unexpected type %T for field %s", value, name)
13731 }
13732 m.SetName(v)
13733 return nil
13734 case storagepolicy.FieldType:
13735 v, ok := value.(string)
13736 if !ok {
13737 return fmt.Errorf("unexpected type %T for field %s", value, name)
13738 }
13739 m.SetType(v)
13740 return nil
13741 case storagepolicy.FieldServer:
13742 v, ok := value.(string)
13743 if !ok {
13744 return fmt.Errorf("unexpected type %T for field %s", value, name)
13745 }
13746 m.SetServer(v)
13747 return nil
13748 case storagepolicy.FieldBucketName:
13749 v, ok := value.(string)
13750 if !ok {
13751 return fmt.Errorf("unexpected type %T for field %s", value, name)
13752 }
13753 m.SetBucketName(v)
13754 return nil
13755 case storagepolicy.FieldIsPrivate:
13756 v, ok := value.(bool)
13757 if !ok {
13758 return fmt.Errorf("unexpected type %T for field %s", value, name)
13759 }
13760 m.SetIsPrivate(v)
13761 return nil

Callers

nothing calls this directly

Calls 15

SetCreatedAtMethod · 0.95
SetUpdatedAtMethod · 0.95
SetDeletedAtMethod · 0.95
SetNameMethod · 0.95
SetTypeMethod · 0.95
SetServerMethod · 0.95
SetBucketNameMethod · 0.95
SetIsPrivateMethod · 0.95
SetAccessKeyMethod · 0.95
SetSecretKeyMethod · 0.95
SetMaxSizeMethod · 0.95
SetDirNameRuleMethod · 0.95

Tested by

no test coverage detected