func (o *Link) AddPollsLinks(ctx context.Context, exec boil.ContextExecutor, insert bool, related ...*PollsLink) error {
	var err error
	for _, rel := range related {
		if insert {
			rel.LinkID = o.LinkID
			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_links\" SET %s WHERE %s",
				strmangle.SetParamNames("\"", "\"", 1, []string{"link_id"}),
				strmangle.WhereClause("\"", "\"", 2, pollsLinkPrimaryKeyColumns),
			)
			values := []interface{}{o.LinkID, rel.PollLinkID}

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

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

	for _, rel := range related {
		if rel.R == nil {
			rel.R = &pollsLinkR{
				Link: o,
			}
		} else {
			rel.R.Link = o
		}
	}
	return nil
}
// AddPollsLinks adds the given related objects to the existing relationships
// of the link, optionally inserting them as new records.
// Appends related to o.R.PollsLinks.
// Sets related.R.Link appropriately.
AddPollsLinks adds the given related objects to the existing relationships
of the link, optionally inserting them as new records.
Appends related to o.R.PollsLinks.
Sets related.R.Link appropriately.
// AddPollsLinks adds the given related objects to the existing relationships // of the link optionally inserting them as new records . // Appends related to o . R . PollsLinks . // Sets related . R . Link appropriately .
func (o *Link) AddPollsLinks(ctx context.Context, exec boil.ContextExecutor, insert bool, related ...*PollsLink) error {
	var err error
	for _, rel := range related {
		if insert {
			rel.LinkID = o.LinkID
			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_links\" SET %s WHERE %s",
				strmangle.SetParamNames("\"", "\"", 1, []string{"link_id"}),
				strmangle.WhereClause("\"", "\"", 2, pollsLinkPrimaryKeyColumns),
			)
			values := []interface{}{o.LinkID, rel.PollLinkID}
			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.LinkID = o.LinkID
		}
	}
	if o.R == nil {
		o.R = &linkR{
			PollsLinks: related,
		}
	} else {
		o.R.PollsLinks = append(o.R.PollsLinks, related...)
	}
	for _, rel := range related {
		if rel.R == nil {
			rel.R = &pollsLinkR{
				Link: o,
			}
		} else {
			rel.R.Link = o
		}
	}
	return nil
}
func ( o * Link ) AddPollsLinks ( ctx context . Context , exec boil . ContextExecutor , insert bool , related ... * PollsLink ) error { var err error for _ , rel := range related { if insert { rel . LinkID = o . LinkID 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 , pollsLinkPrimaryKeyColumns ) , ) values := [ ] interface { } { o . LinkID , rel . PollLinkID } 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 . LinkID = o . LinkID } } if o . R == nil { o . R = & linkR { PollsLinks : related , } } else { o . R . PollsLinks = append ( o . R . PollsLinks , related ... ) } for _ , rel := range related { if rel . R == nil { rel . R = & pollsLinkR { Link : o , } } else { rel . R . Link = o } } return nil }
AddPollsLinks adds the given related objects to the existing relationships
of the link, optionally inserting them as new records.
AddPollsLinks adds the given related objects to the existing relationships of the link optionally inserting them as new records .