// Code generated by ent, DO NOT EDIT. package ent import ( "context" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/crowdsecurity/crowdsec/pkg/database/ent/configitem" "github.com/crowdsecurity/crowdsec/pkg/database/ent/predicate" ) // ConfigItemDelete is the builder for deleting a ConfigItem entity. type ConfigItemDelete struct { config hooks []Hook mutation *ConfigItemMutation } // Where appends a list predicates to the ConfigItemDelete builder. func (cid *ConfigItemDelete) Where(ps ...predicate.ConfigItem) *ConfigItemDelete { cid.mutation.Where(ps...) return cid } // Exec executes the deletion query and returns how many vertices were deleted. func (cid *ConfigItemDelete) Exec(ctx context.Context) (int, error) { return withHooks(ctx, cid.sqlExec, cid.mutation, cid.hooks) } // ExecX is like Exec, but panics if an error occurs. func (cid *ConfigItemDelete) ExecX(ctx context.Context) int { n, err := cid.Exec(ctx) if err != nil { panic(err) } return n } func (cid *ConfigItemDelete) sqlExec(ctx context.Context) (int, error) { _spec := sqlgraph.NewDeleteSpec(configitem.Table, sqlgraph.NewFieldSpec(configitem.FieldID, field.TypeInt)) if ps := cid.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } affected, err := sqlgraph.DeleteNodes(ctx, cid.driver, _spec) if err != nil && sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } cid.mutation.done = true return affected, err } // ConfigItemDeleteOne is the builder for deleting a single ConfigItem entity. type ConfigItemDeleteOne struct { cid *ConfigItemDelete } // Where appends a list predicates to the ConfigItemDelete builder. func (cido *ConfigItemDeleteOne) Where(ps ...predicate.ConfigItem) *ConfigItemDeleteOne { cido.cid.mutation.Where(ps...) return cido } // Exec executes the deletion query. func (cido *ConfigItemDeleteOne) Exec(ctx context.Context) error { n, err := cido.cid.Exec(ctx) switch { case err != nil: return err case n == 0: return &NotFoundError{configitem.Label} default: return nil } } // ExecX is like Exec, but panics if an error occurs. func (cido *ConfigItemDeleteOne) ExecX(ctx context.Context) { if err := cido.Exec(ctx); err != nil { panic(err) } }