entc/gen: add Exec and ExecX to Create builder (#1753)

This commit is contained in:
Tarrence van As
2021-07-23 05:00:47 -07:00
committed by GitHub
parent b9a6b955f8
commit cdfa3e35bb
102 changed files with 1292 additions and 3 deletions

View File

@@ -104,6 +104,19 @@ func (pc *PetCreate) SaveX(ctx context.Context) *Pet {
return v
}
// Exec executes the query.
func (pc *PetCreate) Exec(ctx context.Context) error {
_, err := pc.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (pc *PetCreate) ExecX(ctx context.Context) {
if err := pc.Exec(ctx); err != nil {
panic(err)
}
}
// check runs all checks and user-defined validators on the builder.
func (pc *PetCreate) check() error {
if _, ok := pc.mutation.Name(); !ok {

View File

@@ -106,6 +106,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 {