MCPcopy
hub / github.com/crowdsecurity/crowdsec / sqlSave

Method sqlSave

pkg/database/ent/machine_create.go:328–344  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

326}
327
328func (_c *MachineCreate) sqlSave(ctx context.Context) (*Machine, error) {
329 if err := _c.check(); err != nil {
330 return nil, err
331 }
332 _node, _spec := _c.createSpec()
333 if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
334 if sqlgraph.IsConstraintError(err) {
335 err = &ConstraintError{msg: err.Error(), wrap: err}
336 }
337 return nil, err
338 }
339 id := _spec.ID.Value.(int64)
340 _node.ID = int(id)
341 _c.mutation.id = &_node.ID
342 _c.mutation.done = true
343 return _node, nil
344}
345
346func (_c *MachineCreate) createSpec() (*Machine, *sqlgraph.CreateSpec) {
347 var (

Callers

nothing calls this directly

Calls 3

checkMethod · 0.95
createSpecMethod · 0.95
ErrorMethod · 0.65

Tested by

no test coverage detected