plc.directory mirror
1// Code generated by ent, DO NOT EDIT.
2
3package ent
4
5import (
6 "context"
7
8 "entgo.io/ent/dialect/sql"
9 "entgo.io/ent/dialect/sql/sqlgraph"
10 "entgo.io/ent/schema/field"
11 "tangled.sh/seiso.moe/aletheia.directory/ent/predicate"
12 "tangled.sh/seiso.moe/aletheia.directory/ent/syncstatus"
13)
14
15// SyncStatusDelete is the builder for deleting a SyncStatus entity.
16type SyncStatusDelete struct {
17 config
18 hooks []Hook
19 mutation *SyncStatusMutation
20}
21
22// Where appends a list predicates to the SyncStatusDelete builder.
23func (ssd *SyncStatusDelete) Where(ps ...predicate.SyncStatus) *SyncStatusDelete {
24 ssd.mutation.Where(ps...)
25 return ssd
26}
27
28// Exec executes the deletion query and returns how many vertices were deleted.
29func (ssd *SyncStatusDelete) Exec(ctx context.Context) (int, error) {
30 return withHooks(ctx, ssd.sqlExec, ssd.mutation, ssd.hooks)
31}
32
33// ExecX is like Exec, but panics if an error occurs.
34func (ssd *SyncStatusDelete) ExecX(ctx context.Context) int {
35 n, err := ssd.Exec(ctx)
36 if err != nil {
37 panic(err)
38 }
39 return n
40}
41
42func (ssd *SyncStatusDelete) sqlExec(ctx context.Context) (int, error) {
43 _spec := sqlgraph.NewDeleteSpec(syncstatus.Table, sqlgraph.NewFieldSpec(syncstatus.FieldID, field.TypeInt))
44 if ps := ssd.mutation.predicates; len(ps) > 0 {
45 _spec.Predicate = func(selector *sql.Selector) {
46 for i := range ps {
47 ps[i](selector)
48 }
49 }
50 }
51 affected, err := sqlgraph.DeleteNodes(ctx, ssd.driver, _spec)
52 if err != nil && sqlgraph.IsConstraintError(err) {
53 err = &ConstraintError{msg: err.Error(), wrap: err}
54 }
55 ssd.mutation.done = true
56 return affected, err
57}
58
59// SyncStatusDeleteOne is the builder for deleting a single SyncStatus entity.
60type SyncStatusDeleteOne struct {
61 ssd *SyncStatusDelete
62}
63
64// Where appends a list predicates to the SyncStatusDelete builder.
65func (ssdo *SyncStatusDeleteOne) Where(ps ...predicate.SyncStatus) *SyncStatusDeleteOne {
66 ssdo.ssd.mutation.Where(ps...)
67 return ssdo
68}
69
70// Exec executes the deletion query.
71func (ssdo *SyncStatusDeleteOne) Exec(ctx context.Context) error {
72 n, err := ssdo.ssd.Exec(ctx)
73 switch {
74 case err != nil:
75 return err
76 case n == 0:
77 return &NotFoundError{syncstatus.Label}
78 default:
79 return nil
80 }
81}
82
83// ExecX is like Exec, but panics if an error occurs.
84func (ssdo *SyncStatusDeleteOne) ExecX(ctx context.Context) {
85 if err := ssdo.Exec(ctx); err != nil {
86 panic(err)
87 }
88}