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

@@ -45,6 +45,11 @@ func (cc *CityCreate) AddStreets(s ...*Street) *CityCreate {
return cc.AddStreetIDs(ids...)
}
// Mutation returns the CityMutation object of the builder.
func (cc *CityCreate) Mutation() *CityMutation {
return cc.mutation
}
// Save creates the City in the database.
func (cc *CityCreate) Save(ctx context.Context) (*City, error) {
if _, ok := cc.mutation.Name(); !ok {

View File

@@ -53,6 +53,11 @@ func (cu *CityUpdate) AddStreets(s ...*Street) *CityUpdate {
return cu.AddStreetIDs(ids...)
}
// Mutation returns the CityMutation object of the builder.
func (cu *CityUpdate) Mutation() *CityMutation {
return cu.mutation
}
// RemoveStreetIDs removes the streets edge to Street by ids.
func (cu *CityUpdate) RemoveStreetIDs(ids ...int) *CityUpdate {
cu.mutation.RemoveStreetIDs(ids...)
@@ -222,6 +227,11 @@ func (cuo *CityUpdateOne) AddStreets(s ...*Street) *CityUpdateOne {
return cuo.AddStreetIDs(ids...)
}
// Mutation returns the CityMutation object of the builder.
func (cuo *CityUpdateOne) Mutation() *CityMutation {
return cuo.mutation
}
// RemoveStreetIDs removes the streets edge to Street by ids.
func (cuo *CityUpdateOne) RemoveStreetIDs(ids ...int) *CityUpdateOne {
cuo.mutation.RemoveStreetIDs(ids...)

View File

@@ -49,6 +49,11 @@ func (sc *StreetCreate) SetCity(c *City) *StreetCreate {
return sc.SetCityID(c.ID)
}
// Mutation returns the StreetMutation object of the builder.
func (sc *StreetCreate) Mutation() *StreetMutation {
return sc.mutation
}
// Save creates the Street in the database.
func (sc *StreetCreate) Save(ctx context.Context) (*Street, error) {
if _, ok := sc.mutation.Name(); !ok {

View File

@@ -57,6 +57,11 @@ func (su *StreetUpdate) SetCity(c *City) *StreetUpdate {
return su.SetCityID(c.ID)
}
// Mutation returns the StreetMutation object of the builder.
func (su *StreetUpdate) Mutation() *StreetMutation {
return su.mutation
}
// ClearCity clears the city edge to City.
func (su *StreetUpdate) ClearCity() *StreetUpdate {
su.mutation.ClearCity()
@@ -218,6 +223,11 @@ func (suo *StreetUpdateOne) SetCity(c *City) *StreetUpdateOne {
return suo.SetCityID(c.ID)
}
// Mutation returns the StreetMutation object of the builder.
func (suo *StreetUpdateOne) Mutation() *StreetMutation {
return suo.mutation
}
// ClearCity clears the city edge to City.
func (suo *StreetUpdateOne) ClearCity() *StreetUpdateOne {
suo.mutation.ClearCity()