entc/mutation: expose builder api for getting mutations (#531)

This commit is contained in:
Ariel Mashraki
2020-06-08 15:16:56 +03:00
committed by GitHub
parent 86d345e187
commit 737fb4afda
134 changed files with 1018 additions and 6 deletions

View File

@@ -49,6 +49,11 @@ func (pc *PetCreate) SetOwner(u *User) *PetCreate {
return pc.SetOwnerID(u.ID)
}
// Mutation returns the PetMutation object of the builder.
func (pc *PetCreate) Mutation() *PetMutation {
return pc.mutation
}
// Save creates the Pet in the database.
func (pc *PetCreate) Save(ctx context.Context) (*Pet, error) {
if _, ok := pc.mutation.Name(); !ok {

View File

@@ -57,6 +57,11 @@ func (pu *PetUpdate) SetOwner(u *User) *PetUpdate {
return pu.SetOwnerID(u.ID)
}
// Mutation returns the PetMutation object of the builder.
func (pu *PetUpdate) Mutation() *PetMutation {
return pu.mutation
}
// ClearOwner clears the owner edge to User.
func (pu *PetUpdate) ClearOwner() *PetUpdate {
pu.mutation.ClearOwner()
@@ -218,6 +223,11 @@ func (puo *PetUpdateOne) SetOwner(u *User) *PetUpdateOne {
return puo.SetOwnerID(u.ID)
}
// Mutation returns the PetMutation object of the builder.
func (puo *PetUpdateOne) Mutation() *PetMutation {
return puo.mutation
}
// ClearOwner clears the owner edge to User.
func (puo *PetUpdateOne) ClearOwner() *PetUpdateOne {
puo.mutation.ClearOwner()

View File

@@ -51,6 +51,11 @@ func (uc *UserCreate) AddPets(p ...*Pet) *UserCreate {
return uc.AddPetIDs(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 {

View File

@@ -66,6 +66,11 @@ func (uu *UserUpdate) AddPets(p ...*Pet) *UserUpdate {
return uu.AddPetIDs(ids...)
}
// Mutation returns the UserMutation object of the builder.
func (uu *UserUpdate) Mutation() *UserMutation {
return uu.mutation
}
// RemovePetIDs removes the pets edge to Pet by ids.
func (uu *UserUpdate) RemovePetIDs(ids ...int) *UserUpdate {
uu.mutation.RemovePetIDs(ids...)
@@ -262,6 +267,11 @@ func (uuo *UserUpdateOne) AddPets(p ...*Pet) *UserUpdateOne {
return uuo.AddPetIDs(ids...)
}
// Mutation returns the UserMutation object of the builder.
func (uuo *UserUpdateOne) Mutation() *UserMutation {
return uuo.mutation
}
// RemovePetIDs removes the pets edge to Pet by ids.
func (uuo *UserUpdateOne) RemovePetIDs(ids ...int) *UserUpdateOne {
uuo.mutation.RemovePetIDs(ids...)