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