func (o *Emoji) AddPositions(ctx context.Context, exec boil.ContextExecutor, insert bool, related ...*Position) error {
	var err error
	for _, rel := range related {
		if insert {
			queries.Assign(&rel.EmojiID, o.EmojiID)
			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 \"positions\" SET %s WHERE %s",
				strmangle.SetParamNames("\"", "\"", 1, []string{"emoji_id"}),
				strmangle.WhereClause("\"", "\"", 2, positionPrimaryKeyColumns),
			)
			values := []interface{}{o.EmojiID, rel.PositionID}

			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")
			}

			queries.Assign(&rel.EmojiID, o.EmojiID)
		}
	}

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

	for _, rel := range related {
		if rel.R == nil {
			rel.R = &positionR{
				Emoji: o,
			}
		} else {
			rel.R.Emoji = o
		}
	}
	return nil
}
// AddPositions adds the given related objects to the existing relationships
// of the emoji, optionally inserting them as new records.
// Appends related to o.R.Positions.
// Sets related.R.Emoji appropriately.
AddPositions adds the given related objects to the existing relationships
of the emoji, optionally inserting them as new records.
Appends related to o.R.Positions.
Sets related.R.Emoji appropriately.
// AddPositions adds the given related objects to the existing relationships // of the emoji optionally inserting them as new records . // Appends related to o . R . Positions . // Sets related . R . Emoji appropriately .
func (o *Emoji) AddPositions(ctx context.Context, exec boil.ContextExecutor, insert bool, related ...*Position) error {
	var err error
	for _, rel := range related {
		if insert {
			queries.Assign(&rel.EmojiID, o.EmojiID)
			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 \"positions\" SET %s WHERE %s",
				strmangle.SetParamNames("\"", "\"", 1, []string{"emoji_id"}),
				strmangle.WhereClause("\"", "\"", 2, positionPrimaryKeyColumns),
			)
			values := []interface{}{o.EmojiID, rel.PositionID}
			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")
			}
			queries.Assign(&rel.EmojiID, o.EmojiID)
		}
	}
	if o.R == nil {
		o.R = &emojiR{
			Positions: related,
		}
	} else {
		o.R.Positions = append(o.R.Positions, related...)
	}
	for _, rel := range related {
		if rel.R == nil {
			rel.R = &positionR{
				Emoji: o,
			}
		} else {
			rel.R.Emoji = o
		}
	}
	return nil
}
func ( o * Emoji ) AddPositions ( ctx context . Context , exec boil . ContextExecutor , insert bool , related ... * Position ) error { var err error for _ , rel := range related { if insert { queries . Assign ( & rel . EmojiID , o . EmojiID ) 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 , positionPrimaryKeyColumns ) , ) values := [ ] interface { } { o . EmojiID , rel . PositionID } 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 , " " ) } queries . Assign ( & rel . EmojiID , o . EmojiID ) } } if o . R == nil { o . R = & emojiR { Positions : related , } } else { o . R . Positions = append ( o . R . Positions , related ... ) } for _ , rel := range related { if rel . R == nil { rel . R = & positionR { Emoji : o , } } else { rel . R . Emoji = o } } return nil }
AddPositions adds the given related objects to the existing relationships
of the emoji, optionally inserting them as new records.
AddPositions adds the given related objects to the existing relationships of the emoji optionally inserting them as new records .