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