tss-rocks/backend/ent/dailycategorycontent_delete.go
CDN 05ddc1f783
Some checks failed
Build Backend / Build Docker Image (push) Successful in 3m33s
Test Backend / test (push) Failing after 31s
[feature] migrate to monorepo
2025-02-21 00:49:20 +08:00

88 lines
2.5 KiB
Go

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