func (o *Theme) AddPollsGroups(ctx context.Context, exec boil.ContextExecutor, insert bool, related ...*PollsGroup) error {
	var err error
	for _, rel := range related {
		if insert {
			rel.ThemeID = o.ThemeID
			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 \"polls_groups\" SET %s WHERE %s",
				strmangle.SetParamNames("\"", "\"", 1, []string{"theme_id"}),
				strmangle.WhereClause("\"", "\"", 2, pollsGroupPrimaryKeyColumns),
			)
			values := []interface{}{o.ThemeID, rel.PollGroupID}

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

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

	for _, rel := range related {
		if rel.R == nil {
			rel.R = &pollsGroupR{
				Theme: o,
			}
		} else {
			rel.R.Theme = o
		}
	}
	return nil
}
// AddPollsGroups adds the given related objects to the existing relationships
// of the theme, optionally inserting them as new records.
// Appends related to o.R.PollsGroups.
// Sets related.R.Theme appropriately.
AddPollsGroups adds the given related objects to the existing relationships
of the theme, optionally inserting them as new records.
Appends related to o.R.PollsGroups.
Sets related.R.Theme appropriately.
// AddPollsGroups adds the given related objects to the existing relationships // of the theme optionally inserting them as new records . // Appends related to o . R . PollsGroups . // Sets related . R . Theme appropriately .
func (o *Theme) AddPollsGroups(ctx context.Context, exec boil.ContextExecutor, insert bool, related ...*PollsGroup) error {
	var err error
	for _, rel := range related {
		if insert {
			rel.ThemeID = o.ThemeID
			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 \"polls_groups\" SET %s WHERE %s",
				strmangle.SetParamNames("\"", "\"", 1, []string{"theme_id"}),
				strmangle.WhereClause("\"", "\"", 2, pollsGroupPrimaryKeyColumns),
			)
			values := []interface{}{o.ThemeID, rel.PollGroupID}
			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.ThemeID = o.ThemeID
		}
	}
	if o.R == nil {
		o.R = &themeR{
			PollsGroups: related,
		}
	} else {
		o.R.PollsGroups = append(o.R.PollsGroups, related...)
	}
	for _, rel := range related {
		if rel.R == nil {
			rel.R = &pollsGroupR{
				Theme: o,
			}
		} else {
			rel.R.Theme = o
		}
	}
	return nil
}
func ( o * Theme ) AddPollsGroups ( ctx context . Context , exec boil . ContextExecutor , insert bool , related ... * PollsGroup ) error { var err error for _ , rel := range related { if insert { rel . ThemeID = o . ThemeID 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 , pollsGroupPrimaryKeyColumns ) , ) values := [ ] interface { } { o . ThemeID , rel . PollGroupID } 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 . ThemeID = o . ThemeID } } if o . R == nil { o . R = & themeR { PollsGroups : related , } } else { o . R . PollsGroups = append ( o . R . PollsGroups , related ... ) } for _ , rel := range related { if rel . R == nil { rel . R = & pollsGroupR { Theme : o , } } else { rel . R . Theme = o } } return nil }
AddPollsGroups adds the given related objects to the existing relationships
of the theme, optionally inserting them as new records.
AddPollsGroups adds the given related objects to the existing relationships of the theme optionally inserting them as new records .