func (bpd *BlogPostDelete) Exec(ctx context.Context) (int, error) {
	var (
		err      error
		affected int
	)
	if len(bpd.hooks) == 0 {
		affected, err = bpd.sqlExec(ctx)
	} else {
		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
			mutation, ok := m.(*BlogPostMutation)
			if !ok {
				return nil, fmt.Errorf("unexpected mutation type %T", m)
			}
			bpd.mutation = mutation
			affected, err = bpd.sqlExec(ctx)
			mutation.done = true
			return affected, err
		})
		for i := len(bpd.hooks) - 1; i >= 0; i-- {
			if bpd.hooks[i] == nil {
				return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
			}
			mut = bpd.hooks[i](mut)
		}
		if _, err := mut.Mutate(ctx, bpd.mutation); err != nil {
			return 0, err
		}
	}
	return affected, err
}
Exec executes the deletion query and returns how many vertices were deleted.
package ent
import (
	"context"
	"fmt"
	"entgo.io/contrib/entproto/internal/entprototest/ent/blogpost"
	"entgo.io/contrib/entproto/internal/entprototest/ent/predicate"
	"entgo.io/ent/dialect/sql"
	"entgo.io/ent/dialect/sql/sqlgraph"
	"entgo.io/ent/schema/field"
)
type BlogPostDelete struct {
	config
	hooks    []Hook
	mutation *BlogPostMutation
}
func (bpd *BlogPostDelete) Where(ps ...predicate.BlogPost) *BlogPostDelete {
	bpd.mutation.Where(ps...)
	return bpd
}