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:
@@ -133,6 +133,19 @@ func (fc *FileCreate) SaveX(ctx context.Context) *File {
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (fc *FileCreate) Exec(ctx context.Context) error {
|
||||
_, err := fc.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (fc *FileCreate) ExecX(ctx context.Context) {
|
||||
if err := fc.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (fc *FileCreate) defaults() {
|
||||
if _, ok := fc.mutation.Deleted(); !ok {
|
||||
|
||||
Reference in New Issue
Block a user