mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
entc/mutation: expose builder api for getting mutations (#531)
This commit is contained in:
@@ -56,6 +56,11 @@ func (cc *CarCreate) SetOwner(u *User) *CarCreate {
|
||||
return cc.SetOwnerID(u.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the CarMutation object of the builder.
|
||||
func (cc *CarCreate) Mutation() *CarMutation {
|
||||
return cc.mutation
|
||||
}
|
||||
|
||||
// Save creates the Car in the database.
|
||||
func (cc *CarCreate) Save(ctx context.Context) (*Car, error) {
|
||||
if _, ok := cc.mutation.Model(); !ok {
|
||||
|
||||
@@ -64,6 +64,11 @@ func (cu *CarUpdate) SetOwner(u *User) *CarUpdate {
|
||||
return cu.SetOwnerID(u.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the CarMutation object of the builder.
|
||||
func (cu *CarUpdate) Mutation() *CarMutation {
|
||||
return cu.mutation
|
||||
}
|
||||
|
||||
// ClearOwner clears the owner edge to User.
|
||||
func (cu *CarUpdate) ClearOwner() *CarUpdate {
|
||||
cu.mutation.ClearOwner()
|
||||
@@ -238,6 +243,11 @@ func (cuo *CarUpdateOne) SetOwner(u *User) *CarUpdateOne {
|
||||
return cuo.SetOwnerID(u.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the CarMutation object of the builder.
|
||||
func (cuo *CarUpdateOne) Mutation() *CarMutation {
|
||||
return cuo.mutation
|
||||
}
|
||||
|
||||
// ClearOwner clears the owner edge to User.
|
||||
func (cuo *CarUpdateOne) ClearOwner() *CarUpdateOne {
|
||||
cuo.mutation.ClearOwner()
|
||||
|
||||
@@ -45,6 +45,11 @@ func (gc *GroupCreate) AddUsers(u ...*User) *GroupCreate {
|
||||
return gc.AddUserIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the GroupMutation object of the builder.
|
||||
func (gc *GroupCreate) Mutation() *GroupMutation {
|
||||
return gc.mutation
|
||||
}
|
||||
|
||||
// Save creates the Group in the database.
|
||||
func (gc *GroupCreate) Save(ctx context.Context) (*Group, error) {
|
||||
if _, ok := gc.mutation.Name(); !ok {
|
||||
|
||||
@@ -53,6 +53,11 @@ func (gu *GroupUpdate) AddUsers(u ...*User) *GroupUpdate {
|
||||
return gu.AddUserIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the GroupMutation object of the builder.
|
||||
func (gu *GroupUpdate) Mutation() *GroupMutation {
|
||||
return gu.mutation
|
||||
}
|
||||
|
||||
// RemoveUserIDs removes the users edge to User by ids.
|
||||
func (gu *GroupUpdate) RemoveUserIDs(ids ...int) *GroupUpdate {
|
||||
gu.mutation.RemoveUserIDs(ids...)
|
||||
@@ -227,6 +232,11 @@ func (guo *GroupUpdateOne) AddUsers(u ...*User) *GroupUpdateOne {
|
||||
return guo.AddUserIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the GroupMutation object of the builder.
|
||||
func (guo *GroupUpdateOne) Mutation() *GroupMutation {
|
||||
return guo.mutation
|
||||
}
|
||||
|
||||
// RemoveUserIDs removes the users edge to User by ids.
|
||||
func (guo *GroupUpdateOne) RemoveUserIDs(ids ...int) *GroupUpdateOne {
|
||||
guo.mutation.RemoveUserIDs(ids...)
|
||||
|
||||
@@ -75,6 +75,11 @@ func (uc *UserCreate) AddGroups(g ...*Group) *UserCreate {
|
||||
return uc.AddGroupIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the UserMutation object of the builder.
|
||||
func (uc *UserCreate) Mutation() *UserMutation {
|
||||
return uc.mutation
|
||||
}
|
||||
|
||||
// Save creates the User in the database.
|
||||
func (uc *UserCreate) Save(ctx context.Context) (*User, error) {
|
||||
if _, ok := uc.mutation.Age(); !ok {
|
||||
|
||||
@@ -90,6 +90,11 @@ func (uu *UserUpdate) AddGroups(g ...*Group) *UserUpdate {
|
||||
return uu.AddGroupIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the UserMutation object of the builder.
|
||||
func (uu *UserUpdate) Mutation() *UserMutation {
|
||||
return uu.mutation
|
||||
}
|
||||
|
||||
// RemoveCarIDs removes the cars edge to Car by ids.
|
||||
func (uu *UserUpdate) RemoveCarIDs(ids ...int) *UserUpdate {
|
||||
uu.mutation.RemoveCarIDs(ids...)
|
||||
@@ -367,6 +372,11 @@ func (uuo *UserUpdateOne) AddGroups(g ...*Group) *UserUpdateOne {
|
||||
return uuo.AddGroupIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the UserMutation object of the builder.
|
||||
func (uuo *UserUpdateOne) Mutation() *UserMutation {
|
||||
return uuo.mutation
|
||||
}
|
||||
|
||||
// RemoveCarIDs removes the cars edge to Car by ids.
|
||||
func (uuo *UserUpdateOne) RemoveCarIDs(ids ...int) *UserUpdateOne {
|
||||
uuo.mutation.RemoveCarIDs(ids...)
|
||||
|
||||
Reference in New Issue
Block a user