89 lines
2.3 KiB
Go
89 lines
2.3 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"
|
|
"git.dotya.ml/mirre-mt/pcmt/ent/predicate"
|
|
"git.dotya.ml/mirre-mt/pcmt/ent/searchquery"
|
|
)
|
|
|
|
// SearchQueryDelete is the builder for deleting a SearchQuery entity.
|
|
type SearchQueryDelete struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *SearchQueryMutation
|
|
}
|
|
|
|
// Where appends a list predicates to the SearchQueryDelete builder.
|
|
func (sqd *SearchQueryDelete) Where(ps ...predicate.SearchQuery) *SearchQueryDelete {
|
|
sqd.mutation.Where(ps...)
|
|
return sqd
|
|
}
|
|
|
|
// Exec executes the deletion query and returns how many vertices were deleted.
|
|
func (sqd *SearchQueryDelete) Exec(ctx context.Context) (int, error) {
|
|
return withHooks(ctx, sqd.sqlExec, sqd.mutation, sqd.hooks)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (sqd *SearchQueryDelete) ExecX(ctx context.Context) int {
|
|
n, err := sqd.Exec(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return n
|
|
}
|
|
|
|
func (sqd *SearchQueryDelete) sqlExec(ctx context.Context) (int, error) {
|
|
_spec := sqlgraph.NewDeleteSpec(searchquery.Table, sqlgraph.NewFieldSpec(searchquery.FieldID, field.TypeUUID))
|
|
if ps := sqd.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
affected, err := sqlgraph.DeleteNodes(ctx, sqd.driver, _spec)
|
|
if err != nil && sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
sqd.mutation.done = true
|
|
return affected, err
|
|
}
|
|
|
|
// SearchQueryDeleteOne is the builder for deleting a single SearchQuery entity.
|
|
type SearchQueryDeleteOne struct {
|
|
sqd *SearchQueryDelete
|
|
}
|
|
|
|
// Where appends a list predicates to the SearchQueryDelete builder.
|
|
func (sqdo *SearchQueryDeleteOne) Where(ps ...predicate.SearchQuery) *SearchQueryDeleteOne {
|
|
sqdo.sqd.mutation.Where(ps...)
|
|
return sqdo
|
|
}
|
|
|
|
// Exec executes the deletion query.
|
|
func (sqdo *SearchQueryDeleteOne) Exec(ctx context.Context) error {
|
|
n, err := sqdo.sqd.Exec(ctx)
|
|
switch {
|
|
case err != nil:
|
|
return err
|
|
case n == 0:
|
|
return &NotFoundError{searchquery.Label}
|
|
default:
|
|
return nil
|
|
}
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (sqdo *SearchQueryDeleteOne) ExecX(ctx context.Context) {
|
|
if err := sqdo.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|