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