mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
entc/gen: add Exec and ExecX to Create builder (#1753)
This commit is contained in:
@@ -103,6 +103,19 @@ func (cc *CardCreate) SaveX(ctx context.Context) *Card {
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (cc *CardCreate) Exec(ctx context.Context) error {
|
||||
_, err := cc.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (cc *CardCreate) ExecX(ctx context.Context) {
|
||||
if err := cc.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (cc *CardCreate) check() error {
|
||||
if _, ok := cc.mutation.Expired(); !ok {
|
||||
|
||||
@@ -110,6 +110,19 @@ func (uc *UserCreate) SaveX(ctx context.Context) *User {
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (uc *UserCreate) Exec(ctx context.Context) error {
|
||||
_, err := uc.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (uc *UserCreate) ExecX(ctx context.Context) {
|
||||
if err := uc.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (uc *UserCreate) check() error {
|
||||
if _, ok := uc.mutation.Age(); !ok {
|
||||
|
||||
Reference in New Issue
Block a user