MCPcopy Index your code
hub / github.com/cloudreve/cloudreve / createSpec

Method createSpec

ent/entity_create.go:294–394  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

292}
293
294func (ec *EntityCreate) createSpec() (*Entity, *sqlgraph.CreateSpec) {
295 var (
296 _node = &Entity{config: ec.config}
297 _spec = sqlgraph.NewCreateSpec(entity.Table, sqlgraph.NewFieldSpec(entity.FieldID, field.TypeInt))
298 )
299
300 if id, ok := ec.mutation.ID(); ok {
301 _node.ID = id
302 id64 := int64(id)
303 _spec.ID.Value = id64
304 }
305
306 _spec.OnConflict = ec.conflict
307 if value, ok := ec.mutation.CreatedAt(); ok {
308 _spec.SetField(entity.FieldCreatedAt, field.TypeTime, value)
309 _node.CreatedAt = value
310 }
311 if value, ok := ec.mutation.UpdatedAt(); ok {
312 _spec.SetField(entity.FieldUpdatedAt, field.TypeTime, value)
313 _node.UpdatedAt = value
314 }
315 if value, ok := ec.mutation.DeletedAt(); ok {
316 _spec.SetField(entity.FieldDeletedAt, field.TypeTime, value)
317 _node.DeletedAt = &value
318 }
319 if value, ok := ec.mutation.GetType(); ok {
320 _spec.SetField(entity.FieldType, field.TypeInt, value)
321 _node.Type = value
322 }
323 if value, ok := ec.mutation.Source(); ok {
324 _spec.SetField(entity.FieldSource, field.TypeString, value)
325 _node.Source = value
326 }
327 if value, ok := ec.mutation.Size(); ok {
328 _spec.SetField(entity.FieldSize, field.TypeInt64, value)
329 _node.Size = value
330 }
331 if value, ok := ec.mutation.ReferenceCount(); ok {
332 _spec.SetField(entity.FieldReferenceCount, field.TypeInt, value)
333 _node.ReferenceCount = value
334 }
335 if value, ok := ec.mutation.UploadSessionID(); ok {
336 _spec.SetField(entity.FieldUploadSessionID, field.TypeUUID, value)
337 _node.UploadSessionID = &value
338 }
339 if value, ok := ec.mutation.Props(); ok {
340 _spec.SetField(entity.FieldProps, field.TypeJSON, value)
341 _node.Props = value
342 }
343 if nodes := ec.mutation.FileIDs(); len(nodes) > 0 {
344 edge := &sqlgraph.EdgeSpec{
345 Rel: sqlgraph.M2M,
346 Inverse: true,
347 Table: entity.FileTable,
348 Columns: entity.FilePrimaryKey,
349 Bidi: false,
350 Target: &sqlgraph.EdgeTarget{
351 IDSpec: sqlgraph.NewFieldSpec(file.FieldID, field.TypeInt),

Callers 2

sqlSaveMethod · 0.95
SaveMethod · 0.45

Calls 14

IDMethod · 0.65
CreatedAtMethod · 0.65
UpdatedAtMethod · 0.65
SourceMethod · 0.65
SizeMethod · 0.65
ReferenceCountMethod · 0.65
UploadSessionIDMethod · 0.65
PropsMethod · 0.65
SetFieldMethod · 0.45
DeletedAtMethod · 0.45
GetTypeMethod · 0.45
FileIDsMethod · 0.45

Tested by

no test coverage detected