func (o *UserAccount) AddFactorsLinks(ctx context.Context, exec boil.ContextExecutor, insert bool, related ...*FactorsLink) error {
	var err error
	for _, rel := range related {
		if insert {
			rel.UserAccountID = o.UserAccountID
			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 \"factors_links\" SET %s WHERE %s",
				strmangle.SetParamNames("\"", "\"", 1, []string{"user_account_id"}),
				strmangle.WhereClause("\"", "\"", 2, factorsLinkPrimaryKeyColumns),
			)
			values := []interface{}{o.UserAccountID, rel.FactorsLinkID}

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

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

	for _, rel := range related {
		if rel.R == nil {
			rel.R = &factorsLinkR{
				UserAccount: o,
			}
		} else {
			rel.R.UserAccount = o
		}
	}
	return nil
}
// AddFactorsLinks adds the given related objects to the existing relationships
// of the user_account, optionally inserting them as new records.
// Appends related to o.R.FactorsLinks.
// Sets related.R.UserAccount appropriately.
AddFactorsLinks adds the given related objects to the existing relationships
of the user_account, optionally inserting them as new records.
Appends related to o.R.FactorsLinks.
Sets related.R.UserAccount appropriately.
// AddFactorsLinks adds the given related objects to the existing relationships // of the user_account optionally inserting them as new records . // Appends related to o . R . FactorsLinks . // Sets related . R . UserAccount appropriately .
func (o *UserAccount) AddFactorsLinks(ctx context.Context, exec boil.ContextExecutor, insert bool, related ...*FactorsLink) error {
	var err error
	for _, rel := range related {
		if insert {
			rel.UserAccountID = o.UserAccountID
			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 \"factors_links\" SET %s WHERE %s",
				strmangle.SetParamNames("\"", "\"", 1, []string{"user_account_id"}),
				strmangle.WhereClause("\"", "\"", 2, factorsLinkPrimaryKeyColumns),
			)
			values := []interface{}{o.UserAccountID, rel.FactorsLinkID}
			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.UserAccountID = o.UserAccountID
		}
	}
	if o.R == nil {
		o.R = &userAccountR{
			FactorsLinks: related,
		}
	} else {
		o.R.FactorsLinks = append(o.R.FactorsLinks, related...)
	}
	for _, rel := range related {
		if rel.R == nil {
			rel.R = &factorsLinkR{
				UserAccount: o,
			}
		} else {
			rel.R.UserAccount = o
		}
	}
	return nil
}
func ( o * UserAccount ) AddFactorsLinks ( ctx context . Context , exec boil . ContextExecutor , insert bool , related ... * FactorsLink ) error { var err error for _ , rel := range related { if insert { rel . UserAccountID = o . UserAccountID 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 , factorsLinkPrimaryKeyColumns ) , ) values := [ ] interface { } { o . UserAccountID , rel . FactorsLinkID } 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 . UserAccountID = o . UserAccountID } } if o . R == nil { o . R = & userAccountR { FactorsLinks : related , } } else { o . R . FactorsLinks = append ( o . R . FactorsLinks , related ... ) } for _ , rel := range related { if rel . R == nil { rel . R = & factorsLinkR { UserAccount : o , } } else { rel . R . UserAccount = o } } return nil }
AddFactorsLinks adds the given related objects to the existing relationships
of the user_account, optionally inserting them as new records.
AddFactorsLinks adds the given related objects to the existing relationships of the user_account optionally inserting them as new records .