MCPcopy
hub / github.com/cloudreve/cloudreve / createSpec

Method createSpec

ent/file_create.go:381–558  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

379}
380
381func (fc *FileCreate) createSpec() (*File, *sqlgraph.CreateSpec) {
382 var (
383 _node = &File{config: fc.config}
384 _spec = sqlgraph.NewCreateSpec(file.Table, sqlgraph.NewFieldSpec(file.FieldID, field.TypeInt))
385 )
386
387 if id, ok := fc.mutation.ID(); ok {
388 _node.ID = id
389 id64 := int64(id)
390 _spec.ID.Value = id64
391 }
392
393 _spec.OnConflict = fc.conflict
394 if value, ok := fc.mutation.CreatedAt(); ok {
395 _spec.SetField(file.FieldCreatedAt, field.TypeTime, value)
396 _node.CreatedAt = value
397 }
398 if value, ok := fc.mutation.UpdatedAt(); ok {
399 _spec.SetField(file.FieldUpdatedAt, field.TypeTime, value)
400 _node.UpdatedAt = value
401 }
402 if value, ok := fc.mutation.GetType(); ok {
403 _spec.SetField(file.FieldType, field.TypeInt, value)
404 _node.Type = value
405 }
406 if value, ok := fc.mutation.Name(); ok {
407 _spec.SetField(file.FieldName, field.TypeString, value)
408 _node.Name = value
409 }
410 if value, ok := fc.mutation.Size(); ok {
411 _spec.SetField(file.FieldSize, field.TypeInt64, value)
412 _node.Size = value
413 }
414 if value, ok := fc.mutation.PrimaryEntity(); ok {
415 _spec.SetField(file.FieldPrimaryEntity, field.TypeInt, value)
416 _node.PrimaryEntity = value
417 }
418 if value, ok := fc.mutation.IsSymbolic(); ok {
419 _spec.SetField(file.FieldIsSymbolic, field.TypeBool, value)
420 _node.IsSymbolic = value
421 }
422 if value, ok := fc.mutation.Props(); ok {
423 _spec.SetField(file.FieldProps, field.TypeJSON, value)
424 _node.Props = value
425 }
426 if nodes := fc.mutation.OwnerIDs(); len(nodes) > 0 {
427 edge := &sqlgraph.EdgeSpec{
428 Rel: sqlgraph.M2O,
429 Inverse: true,
430 Table: file.OwnerTable,
431 Columns: []string{file.OwnerColumn},
432 Bidi: false,
433 Target: &sqlgraph.EdgeTarget{
434 IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
435 },
436 }
437 for _, k := range nodes {
438 edge.Target.Nodes = append(edge.Target.Nodes, k)

Callers 2

sqlSaveMethod · 0.95
SaveMethod · 0.45

Calls 15

ParentIDsMethod · 0.80
ChildrenIDsMethod · 0.80
MetadataIDsMethod · 0.80
DirectLinksIDsMethod · 0.80
IDMethod · 0.65
CreatedAtMethod · 0.65
UpdatedAtMethod · 0.65
NameMethod · 0.65
SizeMethod · 0.65
PrimaryEntityMethod · 0.65
IsSymbolicMethod · 0.65
PropsMethod · 0.65

Tested by

no test coverage detected