func (o *Suburb) AddStreets(ctx context.Context, exec boil.ContextExecutor, insert bool, related ...*Street) error {
	var err error
	for _, rel := range related {
		if insert {
			rel.SuburbID = o.SuburbID
			if err = rel.Insert(ctx, exec, boil.Infer()); err != nil {
				return errors.Wrap(err, "failed to insert into foreign table")
			}
		} else {
			updateQuery := fmt.Sprintf(
				"UPDATE \"street\" SET %s WHERE %s",
				strmangle.SetParamNames("\"", "\"", 1, []string{"suburb_id"}),
				strmangle.WhereClause("\"", "\"", 2, streetPrimaryKeyColumns),
			)
			values := []interface{}{o.SuburbID, rel.StreetID}

			if boil.DebugMode {
				fmt.Fprintln(boil.DebugWriter, updateQuery)
				fmt.Fprintln(boil.DebugWriter, values)
			}

			if _, err = exec.ExecContext(ctx, updateQuery, values...); err != nil {
				return errors.Wrap(err, "failed to update foreign table")
			}

			rel.SuburbID = o.SuburbID
		}
	}

	if o.R == nil {
		o.R = &suburbR{
			Streets: related,
		}
	} else {
		o.R.Streets = append(o.R.Streets, related...)
	}

	for _, rel := range related {
		if rel.R == nil {
			rel.R = &streetR{
				Suburb: o,
			}
		} else {
			rel.R.Suburb = o
		}
	}
	return nil
}
// AddStreets adds the given related objects to the existing relationships
// of the suburb, optionally inserting them as new records.
// Appends related to o.R.Streets.
// Sets related.R.Suburb appropriately.
AddStreets adds the given related objects to the existing relationships
of the suburb, optionally inserting them as new records.
Appends related to o.R.Streets.
Sets related.R.Suburb appropriately.
// AddStreets adds the given related objects to the existing relationships // of the suburb optionally inserting them as new records . // Appends related to o . R . Streets . // Sets related . R . Suburb appropriately .
func (o *Suburb) AddStreets(ctx context.Context, exec boil.ContextExecutor, insert bool, related ...*Street) error {
	var err error
	for _, rel := range related {
		if insert {
			rel.SuburbID = o.SuburbID
			if err = rel.Insert(ctx, exec, boil.Infer()); err != nil {
				return errors.Wrap(err, "failed to insert into foreign table")
			}
		} else {
			updateQuery := fmt.Sprintf(
				"UPDATE \"street\" SET %s WHERE %s",
				strmangle.SetParamNames("\"", "\"", 1, []string{"suburb_id"}),
				strmangle.WhereClause("\"", "\"", 2, streetPrimaryKeyColumns),
			)
			values := []interface{}{o.SuburbID, rel.StreetID}
			if boil.DebugMode {
				fmt.Fprintln(boil.DebugWriter, updateQuery)
				fmt.Fprintln(boil.DebugWriter, values)
			}
			if _, err = exec.ExecContext(ctx, updateQuery, values...); err != nil {
				return errors.Wrap(err, "failed to update foreign table")
			}
			rel.SuburbID = o.SuburbID
		}
	}
	if o.R == nil {
		o.R = &suburbR{
			Streets: related,
		}
	} else {
		o.R.Streets = append(o.R.Streets, related...)
	}
	for _, rel := range related {
		if rel.R == nil {
			rel.R = &streetR{
				Suburb: o,
			}
		} else {
			rel.R.Suburb = o
		}
	}
	return nil
}
func ( o * Suburb ) AddStreets ( ctx context . Context , exec boil . ContextExecutor , insert bool , related ... * Street ) error { var err error for _ , rel := range related { if insert { rel . SuburbID = o . SuburbID if err = rel . Insert ( ctx , exec , boil . Infer ( ) ) ; err != nil { return errors . Wrap ( err , " " ) } } else { updateQuery := fmt . Sprintf ( " \" \" " , strmangle . SetParamNames ( " \" " , " \" " , 1 , [ ] string { " " } ) , strmangle . WhereClause ( " \" " , " \" " , 2 , streetPrimaryKeyColumns ) , ) values := [ ] interface { } { o . SuburbID , rel . StreetID } if boil . DebugMode { fmt . Fprintln ( boil . DebugWriter , updateQuery ) fmt . Fprintln ( boil . DebugWriter , values ) } if _ , err = exec . ExecContext ( ctx , updateQuery , values ... ) ; err != nil { return errors . Wrap ( err , " " ) } rel . SuburbID = o . SuburbID } } if o . R == nil { o . R = & suburbR { Streets : related , } } else { o . R . Streets = append ( o . R . Streets , related ... ) } for _ , rel := range related { if rel . R == nil { rel . R = & streetR { Suburb : o , } } else { rel . R . Suburb = o } } return nil }
AddStreets adds the given related objects to the existing relationships
of the suburb, optionally inserting them as new records.
AddStreets adds the given related objects to the existing relationships of the suburb optionally inserting them as new records .