mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
Reviewed By: alexsn Differential Revision: D17119262 fbshipit-source-id: 046f095ca9432c920778db0edb2158dedb23c0a2
66 lines
1.7 KiB
Go
66 lines
1.7 KiB
Go
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
|
// This source code is licensed under the Apache 2.0 license found
|
|
// in the LICENSE file in the root directory of this source tree.
|
|
|
|
// Code generated (@generated) by entc, DO NOT EDIT.
|
|
|
|
package entv2
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/facebookincubator/ent/entc/integration/migrate/entv2/group"
|
|
"github.com/facebookincubator/ent/entc/integration/migrate/entv2/predicate"
|
|
|
|
"github.com/facebookincubator/ent/dialect/sql"
|
|
)
|
|
|
|
// GroupDelete is the builder for deleting a Group entity.
|
|
type GroupDelete struct {
|
|
config
|
|
predicates []predicate.Group
|
|
}
|
|
|
|
// Where adds a new predicate for the builder.
|
|
func (gd *GroupDelete) Where(ps ...predicate.Group) *GroupDelete {
|
|
gd.predicates = append(gd.predicates, ps...)
|
|
return gd
|
|
}
|
|
|
|
// Exec executes the deletion query.
|
|
func (gd *GroupDelete) Exec(ctx context.Context) error {
|
|
return gd.sqlExec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (gd *GroupDelete) ExecX(ctx context.Context) {
|
|
if err := gd.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
func (gd *GroupDelete) sqlExec(ctx context.Context) error {
|
|
var res sql.Result
|
|
selector := sql.Select().From(sql.Table(group.Table))
|
|
for _, p := range gd.predicates {
|
|
p(selector)
|
|
}
|
|
query, args := sql.Delete(group.Table).FromSelect(selector).Query()
|
|
return gd.driver.Exec(ctx, query, args, &res)
|
|
}
|
|
|
|
// GroupDeleteOne is the builder for deleting a single Group entity.
|
|
type GroupDeleteOne struct {
|
|
gd *GroupDelete
|
|
}
|
|
|
|
// Exec executes the deletion query.
|
|
func (gdo *GroupDeleteOne) Exec(ctx context.Context) error {
|
|
return gdo.gd.Exec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (gdo *GroupDeleteOne) ExecX(ctx context.Context) {
|
|
gdo.gd.ExecX(ctx)
|
|
}
|