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

Method sqlSave

pkg/database/ent/decision_create.go:307–323  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

305}
306
307func (_c *DecisionCreate) sqlSave(ctx context.Context) (*Decision, error) {
308 if err := _c.check(); err != nil {
309 return nil, err
310 }
311 _node, _spec := _c.createSpec()
312 if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
313 if sqlgraph.IsConstraintError(err) {
314 err = &ConstraintError{msg: err.Error(), wrap: err}
315 }
316 return nil, err
317 }
318 id := _spec.ID.Value.(int64)
319 _node.ID = int(id)
320 _c.mutation.id = &_node.ID
321 _c.mutation.done = true
322 return _node, nil
323}
324
325func (_c *DecisionCreate) createSpec() (*Decision, *sqlgraph.CreateSpec) {
326 var (

Callers

nothing calls this directly

Calls 3

checkMethod · 0.95
createSpecMethod · 0.95
ErrorMethod · 0.65

Tested by

no test coverage detected