mirror of
https://github.com/stashapp/stash.git
synced 2025-12-06 08:26:00 +01:00
* Move conversions into changesetTranslator * Improve mutation error messages * Use models.New and models.NewPartial everywhere * Replace getStashIDsFor functions * Remove ImageCreateInput * Remove unused parameters * Refactor matching functions --------- Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
27 lines
726 B
Go
27 lines
726 B
Go
package image
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/stashapp/stash/pkg/models"
|
|
)
|
|
|
|
func AddPerformer(ctx context.Context, qb models.ImageUpdater, i *models.Image, performerID int) error {
|
|
imagePartial := models.NewImagePartial()
|
|
imagePartial.PerformerIDs = &models.UpdateIDs{
|
|
IDs: []int{performerID},
|
|
Mode: models.RelationshipUpdateModeAdd,
|
|
}
|
|
_, err := qb.UpdatePartial(ctx, i.ID, imagePartial)
|
|
return err
|
|
}
|
|
|
|
func AddTag(ctx context.Context, qb models.ImageUpdater, i *models.Image, tagID int) error {
|
|
imagePartial := models.NewImagePartial()
|
|
imagePartial.TagIDs = &models.UpdateIDs{
|
|
IDs: []int{tagID},
|
|
Mode: models.RelationshipUpdateModeAdd,
|
|
}
|
|
_, err := qb.UpdatePartial(ctx, i.ID, imagePartial)
|
|
return err
|
|
}
|