mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
Summary: Pull Request resolved: https://github.com/facebookexternal/fbc/pull/1229 Reviewed By: alexsn Differential Revision: D16539934 fbshipit-source-id: b3a8bf1f1be6f65ad3f649cd921ea20fc24182bf
69 lines
1.6 KiB
Go
69 lines
1.6 KiB
Go
// Code generated (@generated) by entc, DO NOT EDIT.
|
|
|
|
package entv2
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
|
|
"fbc/ent/entc/integration/migrate/entv2/predicate"
|
|
"fbc/ent/entc/integration/migrate/entv2/user"
|
|
|
|
"fbc/ent/dialect"
|
|
"fbc/ent/dialect/sql"
|
|
)
|
|
|
|
// UserDelete is the builder for deleting a User entity.
|
|
type UserDelete struct {
|
|
config
|
|
predicates []predicate.User
|
|
}
|
|
|
|
// Where adds a new predicate for the builder.
|
|
func (ud *UserDelete) Where(ps ...predicate.User) *UserDelete {
|
|
ud.predicates = append(ud.predicates, ps...)
|
|
return ud
|
|
}
|
|
|
|
// Exec executes the deletion query.
|
|
func (ud *UserDelete) Exec(ctx context.Context) error {
|
|
switch ud.driver.Dialect() {
|
|
case dialect.MySQL, dialect.SQLite:
|
|
return ud.sqlExec(ctx)
|
|
default:
|
|
return errors.New("entv2: unsupported dialect")
|
|
}
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (ud *UserDelete) ExecX(ctx context.Context) {
|
|
if err := ud.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
func (ud *UserDelete) sqlExec(ctx context.Context) error {
|
|
var res sql.Result
|
|
selector := sql.Select().From(sql.Table(user.Table))
|
|
for _, p := range ud.predicates {
|
|
p(selector)
|
|
}
|
|
query, args := sql.Delete(user.Table).FromSelect(selector).Query()
|
|
return ud.driver.Exec(ctx, query, args, &res)
|
|
}
|
|
|
|
// UserDeleteOne is the builder for deleting a single User entity.
|
|
type UserDeleteOne struct {
|
|
ud *UserDelete
|
|
}
|
|
|
|
// Exec executes the deletion query.
|
|
func (udo *UserDeleteOne) Exec(ctx context.Context) error {
|
|
return udo.ud.Exec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (udo *UserDeleteOne) ExecX(ctx context.Context) {
|
|
udo.ud.ExecX(ctx)
|
|
}
|