func (td *TaskDelete) Exec(ctx context.Context) (int, error) {
	var (
		err      error
		affected int
	)
	if len(td.hooks) == 0 {
		affected, err = td.sqlExec(ctx)
	} else {
		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
			mutation, ok := m.(*TaskMutation)
			if !ok {
				return nil, fmt.Errorf("unexpected mutation type %T", m)
			}
			td.mutation = mutation
			affected, err = td.sqlExec(ctx)
			mutation.done = true
			return affected, err
		})
		for i := len(td.hooks) - 1; i >= 0; i-- {
			mut = td.hooks[i](mut)
		}
		if _, err := mut.Mutate(ctx, td.mutation); err != nil {
			return 0, err
		}
	}
	return affected, err
}
Exec executes the deletion query and returns how many vertices were deleted.
package models
import (
	"context"
	"fmt"
	"entgo.io/ent/dialect/sql"
	"entgo.io/ent/dialect/sql/sqlgraph"
	"entgo.io/ent/schema/field"
	"github.com/adnaan/gomodest-starter/app/gen/models/predicate"
	"github.com/adnaan/gomodest-starter/app/gen/models/task"
)
type TaskDelete struct {
	config
	hooks    []Hook
	mutation *TaskMutation
}
func (td *TaskDelete) Where(ps ...predicate.Task) *TaskDelete {
	td.mutation.predicates = append(td.mutation.predicates, ps...)
	return td
}