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

@@ -48,6 +48,11 @@ func (cc *CardCreate) SetOwner(u *User) *CardCreate {
return cc.SetOwnerID(u.ID)
}
// Mutation returns the CardMutation object of the builder.
func (cc *CardCreate) Mutation() *CardMutation {
return cc.mutation
}
// Save creates the Card in the database.
func (cc *CardCreate) Save(ctx context.Context) (*Card, error) {
if _, ok := cc.mutation.Expired(); !ok {

View File

@@ -57,6 +57,11 @@ func (cu *CardUpdate) SetOwner(u *User) *CardUpdate {
return cu.SetOwnerID(u.ID)
}
// Mutation returns the CardMutation object of the builder.
func (cu *CardUpdate) Mutation() *CardMutation {
return cu.mutation
}
// ClearOwner clears the owner edge to User.
func (cu *CardUpdate) ClearOwner() *CardUpdate {
cu.mutation.ClearOwner()
@@ -226,6 +231,11 @@ func (cuo *CardUpdateOne) SetOwner(u *User) *CardUpdateOne {
return cuo.SetOwnerID(u.ID)
}
// Mutation returns the CardMutation object of the builder.
func (cuo *CardUpdateOne) Mutation() *CardMutation {
return cuo.mutation
}
// ClearOwner clears the owner edge to User.
func (cuo *CardUpdateOne) ClearOwner() *CardUpdateOne {
cuo.mutation.ClearOwner()

View File

@@ -55,6 +55,11 @@ func (uc *UserCreate) SetCard(c *Card) *UserCreate {
return uc.SetCardID(c.ID)
}
// 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

@@ -70,6 +70,11 @@ func (uu *UserUpdate) SetCard(c *Card) *UserUpdate {
return uu.SetCardID(c.ID)
}
// Mutation returns the UserMutation object of the builder.
func (uu *UserUpdate) Mutation() *UserMutation {
return uu.mutation
}
// ClearCard clears the card edge to Card.
func (uu *UserUpdate) ClearCard() *UserUpdate {
uu.mutation.ClearCard()
@@ -258,6 +263,11 @@ func (uuo *UserUpdateOne) SetCard(c *Card) *UserUpdateOne {
return uuo.SetCardID(c.ID)
}
// Mutation returns the UserMutation object of the builder.
func (uuo *UserUpdateOne) Mutation() *UserMutation {
return uuo.mutation
}
// ClearCard clears the card edge to Card.
func (uuo *UserUpdateOne) ClearCard() *UserUpdateOne {
uuo.mutation.ClearCard()