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