Files

89 lines
2.4 KiB
Go
Raw Permalink Normal View History

2022-08-29 11:16:12 +04:00
// Code generated by ent, DO NOT EDIT.
2021-01-02 00:34:47 +04:00
package db
import (
"context"
2021-03-24 10:37:51 +04:00
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
2021-01-02 00:34:47 +04:00
"github.com/dexidp/dex/storage/ent/db/devicerequest"
"github.com/dexidp/dex/storage/ent/db/predicate"
)
// DeviceRequestDelete is the builder for deleting a DeviceRequest entity.
type DeviceRequestDelete struct {
config
hooks []Hook
mutation *DeviceRequestMutation
}
2021-09-13 17:48:02 +04:00
// Where appends a list predicates to the DeviceRequestDelete builder.
2025-08-18 12:53:54 +02:00
func (_d *DeviceRequestDelete) Where(ps ...predicate.DeviceRequest) *DeviceRequestDelete {
_d.mutation.Where(ps...)
return _d
2021-01-02 00:34:47 +04:00
}
// Exec executes the deletion query and returns how many vertices were deleted.
2025-08-18 12:53:54 +02:00
func (_d *DeviceRequestDelete) Exec(ctx context.Context) (int, error) {
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
2021-01-02 00:34:47 +04:00
}
// ExecX is like Exec, but panics if an error occurs.
2025-08-18 12:53:54 +02:00
func (_d *DeviceRequestDelete) ExecX(ctx context.Context) int {
n, err := _d.Exec(ctx)
2021-01-02 00:34:47 +04:00
if err != nil {
panic(err)
}
return n
}
2025-08-18 12:53:54 +02:00
func (_d *DeviceRequestDelete) sqlExec(ctx context.Context) (int, error) {
2023-02-26 01:32:52 +01:00
_spec := sqlgraph.NewDeleteSpec(devicerequest.Table, sqlgraph.NewFieldSpec(devicerequest.FieldID, field.TypeInt))
2025-08-18 12:53:54 +02:00
if ps := _d.mutation.predicates; len(ps) > 0 {
2021-01-02 00:34:47 +04:00
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
2025-08-18 12:53:54 +02:00
affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
2022-08-29 11:16:12 +04:00
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
2025-08-18 12:53:54 +02:00
_d.mutation.done = true
2022-08-29 11:16:12 +04:00
return affected, err
2021-01-02 00:34:47 +04:00
}
// DeviceRequestDeleteOne is the builder for deleting a single DeviceRequest entity.
type DeviceRequestDeleteOne struct {
2025-08-18 12:53:54 +02:00
_d *DeviceRequestDelete
2021-01-02 00:34:47 +04:00
}
2023-02-26 01:32:52 +01:00
// Where appends a list predicates to the DeviceRequestDelete builder.
2025-08-18 12:53:54 +02:00
func (_d *DeviceRequestDeleteOne) Where(ps ...predicate.DeviceRequest) *DeviceRequestDeleteOne {
_d._d.mutation.Where(ps...)
return _d
2023-02-26 01:32:52 +01:00
}
2021-01-02 00:34:47 +04:00
// Exec executes the deletion query.
2025-08-18 12:53:54 +02:00
func (_d *DeviceRequestDeleteOne) Exec(ctx context.Context) error {
n, err := _d._d.Exec(ctx)
2021-01-02 00:34:47 +04:00
switch {
case err != nil:
return err
case n == 0:
return &NotFoundError{devicerequest.Label}
default:
return nil
}
}
// ExecX is like Exec, but panics if an error occurs.
2025-08-18 12:53:54 +02:00
func (_d *DeviceRequestDeleteOne) ExecX(ctx context.Context) {
if err := _d.Exec(ctx); err != nil {
2023-02-26 01:32:52 +01:00
panic(err)
}
2021-01-02 00:34:47 +04:00
}