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