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

@@ -100,6 +100,19 @@ func (cc *CityCreate) SaveX(ctx context.Context) *City {
return v
}
// Exec executes the query.
func (cc *CityCreate) Exec(ctx context.Context) error {
_, err := cc.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (cc *CityCreate) 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 *CityCreate) check() error {
if _, ok := cc.mutation.Name(); !ok {

View File

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