Files
polaris/ent/notificationclient_delete.go
2024-07-29 15:56:29 +08:00

89 lines
2.5 KiB
Go

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