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