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