mirror of
https://github.com/ent/ent.git
synced 2026-05-28 09:49:08 +03:00
entc/gen: add Exec and ExecX to Create builder (#1753)
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user