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