MCPcopy
hub / github.com/cloudreve/cloudreve / SetField

Method SetField

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

4135// the field is not defined in the schema, or if the type mismatched the field
4136// type.
4137func (m *FileMutation) SetField(name string, value ent.Value) error {
4138 switch name {
4139 case file.FieldCreatedAt:
4140 v, ok := value.(time.Time)
4141 if !ok {
4142 return fmt.Errorf("unexpected type %T for field %s", value, name)
4143 }
4144 m.SetCreatedAt(v)
4145 return nil
4146 case file.FieldUpdatedAt:
4147 v, ok := value.(time.Time)
4148 if !ok {
4149 return fmt.Errorf("unexpected type %T for field %s", value, name)
4150 }
4151 m.SetUpdatedAt(v)
4152 return nil
4153 case file.FieldType:
4154 v, ok := value.(int)
4155 if !ok {
4156 return fmt.Errorf("unexpected type %T for field %s", value, name)
4157 }
4158 m.SetType(v)
4159 return nil
4160 case file.FieldName:
4161 v, ok := value.(string)
4162 if !ok {
4163 return fmt.Errorf("unexpected type %T for field %s", value, name)
4164 }
4165 m.SetName(v)
4166 return nil
4167 case file.FieldOwnerID:
4168 v, ok := value.(int)
4169 if !ok {
4170 return fmt.Errorf("unexpected type %T for field %s", value, name)
4171 }
4172 m.SetOwnerID(v)
4173 return nil
4174 case file.FieldSize:
4175 v, ok := value.(int64)
4176 if !ok {
4177 return fmt.Errorf("unexpected type %T for field %s", value, name)
4178 }
4179 m.SetSize(v)
4180 return nil
4181 case file.FieldPrimaryEntity:
4182 v, ok := value.(int)
4183 if !ok {
4184 return fmt.Errorf("unexpected type %T for field %s", value, name)
4185 }
4186 m.SetPrimaryEntity(v)
4187 return nil
4188 case file.FieldFileChildren:
4189 v, ok := value.(int)
4190 if !ok {
4191 return fmt.Errorf("unexpected type %T for field %s", value, name)
4192 }
4193 m.SetFileChildren(v)
4194 return nil

Callers 15

sqlSaveMethod · 0.45
sqlSaveMethod · 0.45
sqlSaveMethod · 0.45
sqlSaveMethod · 0.45
createSpecMethod · 0.45
sqlSaveMethod · 0.45
sqlSaveMethod · 0.45
sqlSaveMethod · 0.45
sqlSaveMethod · 0.45
sqlSaveMethod · 0.45
sqlSaveMethod · 0.45
sqlSaveMethod · 0.45

Calls 11

SetCreatedAtMethod · 0.95
SetUpdatedAtMethod · 0.95
SetTypeMethod · 0.95
SetNameMethod · 0.95
SetOwnerIDMethod · 0.95
SetSizeMethod · 0.95
SetPrimaryEntityMethod · 0.95
SetFileChildrenMethod · 0.95
SetIsSymbolicMethod · 0.95
SetPropsMethod · 0.95
SetStoragePolicyFilesMethod · 0.95

Tested by

no test coverage detected