| 1 |
// Code generated by ent, DO NOT EDIT. |
| 2 |
|
| 3 |
package ent |
| 4 |
|
| 5 |
import ( |
| 6 |
"context" |
| 7 |
|
| 8 |
"entgo.io/ent/dialect/sql" |
| 9 |
"entgo.io/ent/dialect/sql/sqlgraph" |
| 10 |
"entgo.io/ent/schema/field" |
| 11 |
"github.com/in-toto/archivista/ent/attestationpolicy" |
| 12 |
"github.com/in-toto/archivista/ent/predicate" |
| 13 |
) |
| 14 |
|
| 15 |
// AttestationPolicyDelete is the builder for deleting a AttestationPolicy entity. |
| 16 |
type AttestationPolicyDelete struct { |
| 17 |
config |
| 18 |
hooks []Hook |
| 19 |
mutation *AttestationPolicyMutation |
| 20 |
} |
| 21 |
|
| 22 |
// Where appends a list predicates to the AttestationPolicyDelete builder. |
| 23 |
func (_d *AttestationPolicyDelete) Where(ps ...predicate.AttestationPolicy) *AttestationPolicyDelete { |
| 24 |
_d.mutation.Where(ps...) |
| 25 |
return _d |
| 26 |
} |
| 27 |
|
| 28 |
// Exec executes the deletion query and returns how many vertices were deleted. |
| 29 |
func (_d *AttestationPolicyDelete) Exec(ctx context.Context) (int, error) { |
| 30 |
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) |
| 31 |
} |
| 32 |
|
| 33 |
// ExecX is like Exec, but panics if an error occurs. |
| 34 |
func (_d *AttestationPolicyDelete) ExecX(ctx context.Context) int { |
| 35 |
n, err := _d.Exec(ctx) |
| 36 |
if err != nil { |
| 37 |
panic(err) |
| 38 |
} |
| 39 |
return n |
| 40 |
} |
| 41 |
|
| 42 |
func (_d *AttestationPolicyDelete) sqlExec(ctx context.Context) (int, error) { |
| 43 |
_spec := sqlgraph.NewDeleteSpec(attestationpolicy.Table, sqlgraph.NewFieldSpec(attestationpolicy.FieldID, field.TypeUUID)) |
| 44 |
if ps := _d.mutation.predicates; len(ps) > 0 { |
| 45 |
_spec.Predicate = func(selector *sql.Selector) { |
| 46 |
for i := range ps { |
| 47 |
ps[i](selector) |
| 48 |
} |
| 49 |
} |
| 50 |
} |
| 51 |
affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) |
| 52 |
if err != nil && sqlgraph.IsConstraintError(err) { |
| 53 |
err = &ConstraintError{msg: err.Error(), wrap: err} |
| 54 |
} |
| 55 |
_d.mutation.done = true |
| 56 |
return affected, err |
| 57 |
} |
| 58 |
|
| 59 |
// AttestationPolicyDeleteOne is the builder for deleting a single AttestationPolicy entity. |
| 60 |
type AttestationPolicyDeleteOne struct { |
| 61 |
_d *AttestationPolicyDelete |
| 62 |
} |
| 63 |
|
| 64 |
// Where appends a list predicates to the AttestationPolicyDelete builder. |
| 65 |
func (_d *AttestationPolicyDeleteOne) Where(ps ...predicate.AttestationPolicy) *AttestationPolicyDeleteOne { |
| 66 |
_d._d.mutation.Where(ps...) |
| 67 |
return _d |
| 68 |
} |
| 69 |
|
| 70 |
// Exec executes the deletion query. |
| 71 |
func (_d *AttestationPolicyDeleteOne) Exec(ctx context.Context) error { |
| 72 |
n, err := _d._d.Exec(ctx) |
| 73 |
switch { |
| 74 |
case err != nil: |
| 75 |
return err |
| 76 |
case n == 0: |
| 77 |
return &NotFoundError{attestationpolicy.Label} |
| 78 |
default: |
| 79 |
return nil |
| 80 |
} |
| 81 |
} |
| 82 |
|
| 83 |
// ExecX is like Exec, but panics if an error occurs. |
| 84 |
func (_d *AttestationPolicyDeleteOne) ExecX(ctx context.Context) { |
| 85 |
if err := _d.Exec(ctx); err != nil { |
| 86 |
panic(err) |
| 87 |
} |
| 88 |
} |