func (o *Street) AddAddresses(ctx context.Context, exec boil.ContextExecutor, insert bool, related ...*Address) error {
	var err error
	for _, rel := range related {
		if insert {
			rel.StreetID = o.StreetID
			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 \"address\" SET %s WHERE %s",
				strmangle.SetParamNames("\"", "\"", 1, []string{"street_id"}),
				strmangle.WhereClause("\"", "\"", 2, addressPrimaryKeyColumns),
			)
			values := []interface{}{o.StreetID, rel.AddressID}

			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.StreetID = o.StreetID
		}
	}

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

	for _, rel := range related {
		if rel.R == nil {
			rel.R = &addressR{
				Street: o,
			}
		} else {
			rel.R.Street = o
		}
	}
	return nil
}
// AddAddresses adds the given related objects to the existing relationships
// of the street, optionally inserting them as new records.
// Appends related to o.R.Addresses.
// Sets related.R.Street appropriately.
AddAddresses adds the given related objects to the existing relationships
of the street, optionally inserting them as new records.
Appends related to o.R.Addresses.
Sets related.R.Street appropriately.
// AddAddresses adds the given related objects to the existing relationships // of the street optionally inserting them as new records . // Appends related to o . R . Addresses . // Sets related . R . Street appropriately .
func (o *Street) AddAddresses(ctx context.Context, exec boil.ContextExecutor, insert bool, related ...*Address) error {
	var err error
	for _, rel := range related {
		if insert {
			rel.StreetID = o.StreetID
			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 \"address\" SET %s WHERE %s",
				strmangle.SetParamNames("\"", "\"", 1, []string{"street_id"}),
				strmangle.WhereClause("\"", "\"", 2, addressPrimaryKeyColumns),
			)
			values := []interface{}{o.StreetID, rel.AddressID}
			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.StreetID = o.StreetID
		}
	}
	if o.R == nil {
		o.R = &streetR{
			Addresses: related,
		}
	} else {
		o.R.Addresses = append(o.R.Addresses, related...)
	}
	for _, rel := range related {
		if rel.R == nil {
			rel.R = &addressR{
				Street: o,
			}
		} else {
			rel.R.Street = o
		}
	}
	return nil
}
func ( o * Street ) AddAddresses ( ctx context . Context , exec boil . ContextExecutor , insert bool , related ... * Address ) error { var err error for _ , rel := range related { if insert { rel . StreetID = o . StreetID 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 , addressPrimaryKeyColumns ) , ) values := [ ] interface { } { o . StreetID , rel . AddressID } 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 . StreetID = o . StreetID } } if o . R == nil { o . R = & streetR { Addresses : related , } } else { o . R . Addresses = append ( o . R . Addresses , related ... ) } for _ , rel := range related { if rel . R == nil { rel . R = & addressR { Street : o , } } else { rel . R . Street = o } } return nil }
AddAddresses adds the given related objects to the existing relationships
of the street, optionally inserting them as new records.
AddAddresses adds the given related objects to the existing relationships of the street optionally inserting them as new records .