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

Method sqlSave

pkg/database/ent/allowlist_create.go:171–187  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

169}
170
171func (_c *AllowListCreate) sqlSave(ctx context.Context) (*AllowList, error) {
172 if err := _c.check(); err != nil {
173 return nil, err
174 }
175 _node, _spec := _c.createSpec()
176 if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
177 if sqlgraph.IsConstraintError(err) {
178 err = &ConstraintError{msg: err.Error(), wrap: err}
179 }
180 return nil, err
181 }
182 id := _spec.ID.Value.(int64)
183 _node.ID = int(id)
184 _c.mutation.id = &_node.ID
185 _c.mutation.done = true
186 return _node, nil
187}
188
189func (_c *AllowListCreate) createSpec() (*AllowList, *sqlgraph.CreateSpec) {
190 var (

Callers

nothing calls this directly

Calls 3

checkMethod · 0.95
createSpecMethod · 0.95
ErrorMethod · 0.65

Tested by

no test coverage detected