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

Method createSpec

ent/task_create.go:258–321  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

256}
257
258func (tc *TaskCreate) createSpec() (*Task, *sqlgraph.CreateSpec) {
259 var (
260 _node = &Task{config: tc.config}
261 _spec = sqlgraph.NewCreateSpec(task.Table, sqlgraph.NewFieldSpec(task.FieldID, field.TypeInt))
262 )
263
264 if id, ok := tc.mutation.ID(); ok {
265 _node.ID = id
266 id64 := int64(id)
267 _spec.ID.Value = id64
268 }
269
270 _spec.OnConflict = tc.conflict
271 if value, ok := tc.mutation.CreatedAt(); ok {
272 _spec.SetField(task.FieldCreatedAt, field.TypeTime, value)
273 _node.CreatedAt = value
274 }
275 if value, ok := tc.mutation.UpdatedAt(); ok {
276 _spec.SetField(task.FieldUpdatedAt, field.TypeTime, value)
277 _node.UpdatedAt = value
278 }
279 if value, ok := tc.mutation.DeletedAt(); ok {
280 _spec.SetField(task.FieldDeletedAt, field.TypeTime, value)
281 _node.DeletedAt = &value
282 }
283 if value, ok := tc.mutation.GetType(); ok {
284 _spec.SetField(task.FieldType, field.TypeString, value)
285 _node.Type = value
286 }
287 if value, ok := tc.mutation.Status(); ok {
288 _spec.SetField(task.FieldStatus, field.TypeEnum, value)
289 _node.Status = value
290 }
291 if value, ok := tc.mutation.PublicState(); ok {
292 _spec.SetField(task.FieldPublicState, field.TypeJSON, value)
293 _node.PublicState = value
294 }
295 if value, ok := tc.mutation.PrivateState(); ok {
296 _spec.SetField(task.FieldPrivateState, field.TypeString, value)
297 _node.PrivateState = value
298 }
299 if value, ok := tc.mutation.CorrelationID(); ok {
300 _spec.SetField(task.FieldCorrelationID, field.TypeUUID, value)
301 _node.CorrelationID = value
302 }
303 if nodes := tc.mutation.UserIDs(); len(nodes) > 0 {
304 edge := &sqlgraph.EdgeSpec{
305 Rel: sqlgraph.M2O,
306 Inverse: true,
307 Table: task.UserTable,
308 Columns: []string{task.UserColumn},
309 Bidi: false,
310 Target: &sqlgraph.EdgeTarget{
311 IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
312 },
313 }
314 for _, k := range nodes {
315 edge.Target.Nodes = append(edge.Target.Nodes, k)

Callers 2

sqlSaveMethod · 0.95
SaveMethod · 0.45

Calls 11

PublicStateMethod · 0.80
PrivateStateMethod · 0.80
IDMethod · 0.65
CreatedAtMethod · 0.65
UpdatedAtMethod · 0.65
StatusMethod · 0.65
CorrelationIDMethod · 0.65
SetFieldMethod · 0.45
DeletedAtMethod · 0.45
GetTypeMethod · 0.45
UserIDsMethod · 0.45

Tested by

no test coverage detected