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 ent
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/facebookincubator/ent/examples/o2mrecur/ent/node"
|
|
"github.com/facebookincubator/ent/examples/o2mrecur/ent/predicate"
|
|
|
|
"github.com/facebookincubator/ent/dialect/sql"
|
|
)
|
|
|
|
// NodeDelete is the builder for deleting a Node entity.
|
|
type NodeDelete struct {
|
|
config
|
|
predicates []predicate.Node
|
|
}
|
|
|
|
// Where adds a new predicate for the builder.
|
|
func (nd *NodeDelete) Where(ps ...predicate.Node) *NodeDelete {
|
|
nd.predicates = append(nd.predicates, ps...)
|
|
return nd
|
|
}
|
|
|
|
// Exec executes the deletion query.
|
|
func (nd *NodeDelete) Exec(ctx context.Context) error {
|
|
return nd.sqlExec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (nd *NodeDelete) ExecX(ctx context.Context) {
|
|
if err := nd.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
func (nd *NodeDelete) sqlExec(ctx context.Context) error {
|
|
var res sql.Result
|
|
selector := sql.Select().From(sql.Table(node.Table))
|
|
for _, p := range nd.predicates {
|
|
p(selector)
|
|
}
|
|
query, args := sql.Delete(node.Table).FromSelect(selector).Query()
|
|
return nd.driver.Exec(ctx, query, args, &res)
|
|
}
|
|
|
|
// NodeDeleteOne is the builder for deleting a single Node entity.
|
|
type NodeDeleteOne struct {
|
|
nd *NodeDelete
|
|
}
|
|
|
|
// Exec executes the deletion query.
|
|
func (ndo *NodeDeleteOne) Exec(ctx context.Context) error {
|
|
return ndo.nd.Exec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (ndo *NodeDeleteOne) ExecX(ctx context.Context) {
|
|
ndo.nd.ExecX(ctx)
|
|
}
|