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

Method sqlSave

pkg/database/ent/alert_create.go:521–537  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

519}
520
521func (_c *AlertCreate) sqlSave(ctx context.Context) (*Alert, error) {
522 if err := _c.check(); err != nil {
523 return nil, err
524 }
525 _node, _spec := _c.createSpec()
526 if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
527 if sqlgraph.IsConstraintError(err) {
528 err = &ConstraintError{msg: err.Error(), wrap: err}
529 }
530 return nil, err
531 }
532 id := _spec.ID.Value.(int64)
533 _node.ID = int(id)
534 _c.mutation.id = &_node.ID
535 _c.mutation.done = true
536 return _node, nil
537}
538
539func (_c *AlertCreate) createSpec() (*Alert, *sqlgraph.CreateSpec) {
540 var (

Callers

nothing calls this directly

Calls 3

checkMethod · 0.95
createSpecMethod · 0.95
ErrorMethod · 0.65

Tested by

no test coverage detected