// 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.noahlan.cn/n-admin/n-admin-server/rpc/core/ent/predicate" "git.noahlan.cn/n-admin/n-admin-server/rpc/core/ent/usersocial" ) // UserSocialDelete is the builder for deleting a UserSocial entity. type UserSocialDelete struct { config hooks []Hook mutation *UserSocialMutation } // Where appends a list predicates to the UserSocialDelete builder. func (usd *UserSocialDelete) Where(ps ...predicate.UserSocial) *UserSocialDelete { usd.mutation.Where(ps...) return usd } // Exec executes the deletion query and returns how many vertices were deleted. func (usd *UserSocialDelete) Exec(ctx context.Context) (int, error) { return withHooks(ctx, usd.sqlExec, usd.mutation, usd.hooks) } // ExecX is like Exec, but panics if an error occurs. func (usd *UserSocialDelete) ExecX(ctx context.Context) int { n, err := usd.Exec(ctx) if err != nil { panic(err) } return n } func (usd *UserSocialDelete) sqlExec(ctx context.Context) (int, error) { _spec := sqlgraph.NewDeleteSpec(usersocial.Table, sqlgraph.NewFieldSpec(usersocial.FieldID, field.TypeInt64)) if ps := usd.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } affected, err := sqlgraph.DeleteNodes(ctx, usd.driver, _spec) if err != nil && sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } usd.mutation.done = true return affected, err } // UserSocialDeleteOne is the builder for deleting a single UserSocial entity. type UserSocialDeleteOne struct { usd *UserSocialDelete } // Where appends a list predicates to the UserSocialDelete builder. func (usdo *UserSocialDeleteOne) Where(ps ...predicate.UserSocial) *UserSocialDeleteOne { usdo.usd.mutation.Where(ps...) return usdo } // Exec executes the deletion query. func (usdo *UserSocialDeleteOne) Exec(ctx context.Context) error { n, err := usdo.usd.Exec(ctx) switch { case err != nil: return err case n == 0: return &NotFoundError{usersocial.Label} default: return nil } } // ExecX is like Exec, but panics if an error occurs. func (usdo *UserSocialDeleteOne) ExecX(ctx context.Context) { if err := usdo.Exec(ctx); err != nil { panic(err) } }