// 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/reportvulnerability"
)
// ReportVulnerabilityDelete is the builder for deleting a ReportVulnerability entity.
type ReportVulnerabilityDelete struct {
config
hooks []Hook
mutation *ReportVulnerabilityMutation
}
// Where appends a list predicates to the ReportVulnerabilityDelete builder.
func (rvd *ReportVulnerabilityDelete) Where(ps ...predicate.ReportVulnerability) *ReportVulnerabilityDelete {
rvd.mutation.Where(ps...)
return rvd
}
// Exec executes the deletion query and returns how many vertices were deleted.
func (rvd *ReportVulnerabilityDelete) Exec(ctx context.Context) (int, error) {
return withHooks(ctx, rvd.sqlExec, rvd.mutation, rvd.hooks)
}
// ExecX is like Exec, but panics if an error occurs.
func (rvd *ReportVulnerabilityDelete) ExecX(ctx context.Context) int {
n, err := rvd.Exec(ctx)
if err != nil {
panic(err)
}
return n
}
func (rvd *ReportVulnerabilityDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(reportvulnerability.Table, sqlgraph.NewFieldSpec(reportvulnerability.FieldID, field.TypeInt))
if ps := rvd.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
affected, err := sqlgraph.DeleteNodes(ctx, rvd.driver, _spec)
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
rvd.mutation.done = true
return affected, err
}
// ReportVulnerabilityDeleteOne is the builder for deleting a single ReportVulnerability entity.
type ReportVulnerabilityDeleteOne struct {
rvd *ReportVulnerabilityDelete
}
// Where appends a list predicates to the ReportVulnerabilityDelete builder.
func (rvdo *ReportVulnerabilityDeleteOne) Where(ps ...predicate.ReportVulnerability) *ReportVulnerabilityDeleteOne {
rvdo.rvd.mutation.Where(ps...)
return rvdo
}
// Exec executes the deletion query.
func (rvdo *ReportVulnerabilityDeleteOne) Exec(ctx context.Context) error {
n, err := rvdo.rvd.Exec(ctx)
switch {
case err != nil:
return err
case n == 0:
return &NotFoundError{reportvulnerability.Label}
default:
return nil
}
}
// ExecX is like Exec, but panics if an error occurs.
func (rvdo *ReportVulnerabilityDeleteOne) ExecX(ctx context.Context) {
if err := rvdo.Exec(ctx); err != nil {
panic(err)
}
}