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