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

Method createSpec

ent/fsevent_create.go:203–254  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

201}
202
203func (fec *FsEventCreate) createSpec() (*FsEvent, *sqlgraph.CreateSpec) {
204 var (
205 _node = &FsEvent{config: fec.config}
206 _spec = sqlgraph.NewCreateSpec(fsevent.Table, sqlgraph.NewFieldSpec(fsevent.FieldID, field.TypeInt))
207 )
208
209 if id, ok := fec.mutation.ID(); ok {
210 _node.ID = id
211 id64 := int64(id)
212 _spec.ID.Value = id64
213 }
214
215 _spec.OnConflict = fec.conflict
216 if value, ok := fec.mutation.CreatedAt(); ok {
217 _spec.SetField(fsevent.FieldCreatedAt, field.TypeTime, value)
218 _node.CreatedAt = value
219 }
220 if value, ok := fec.mutation.UpdatedAt(); ok {
221 _spec.SetField(fsevent.FieldUpdatedAt, field.TypeTime, value)
222 _node.UpdatedAt = value
223 }
224 if value, ok := fec.mutation.DeletedAt(); ok {
225 _spec.SetField(fsevent.FieldDeletedAt, field.TypeTime, value)
226 _node.DeletedAt = &value
227 }
228 if value, ok := fec.mutation.Event(); ok {
229 _spec.SetField(fsevent.FieldEvent, field.TypeString, value)
230 _node.Event = value
231 }
232 if value, ok := fec.mutation.Subscriber(); ok {
233 _spec.SetField(fsevent.FieldSubscriber, field.TypeUUID, value)
234 _node.Subscriber = value
235 }
236 if nodes := fec.mutation.UserIDs(); len(nodes) > 0 {
237 edge := &sqlgraph.EdgeSpec{
238 Rel: sqlgraph.M2O,
239 Inverse: true,
240 Table: fsevent.UserTable,
241 Columns: []string{fsevent.UserColumn},
242 Bidi: false,
243 Target: &sqlgraph.EdgeTarget{
244 IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
245 },
246 }
247 for _, k := range nodes {
248 edge.Target.Nodes = append(edge.Target.Nodes, k)
249 }
250 _node.UserFsevent = nodes[0]
251 _spec.Edges = append(_spec.Edges, edge)
252 }
253 return _node, _spec
254}
255
256// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
257// of the `INSERT` statement. For example:

Callers 2

sqlSaveMethod · 0.95
SaveMethod · 0.45

Calls 8

EventMethod · 0.80
SubscriberMethod · 0.80
IDMethod · 0.65
CreatedAtMethod · 0.65
UpdatedAtMethod · 0.65
SetFieldMethod · 0.45
DeletedAtMethod · 0.45
UserIDsMethod · 0.45

Tested by

no test coverage detected