2021-01-18 01:23:20 +00:00
|
|
|
package image
|
|
|
|
|
2021-05-03 03:09:46 +00:00
|
|
|
import (
|
2022-05-19 07:49:32 +00:00
|
|
|
"context"
|
|
|
|
|
2021-05-03 03:09:46 +00:00
|
|
|
"github.com/stashapp/stash/pkg/models"
|
|
|
|
)
|
2021-01-18 01:23:20 +00:00
|
|
|
|
2023-09-01 00:39:29 +00:00
|
|
|
func AddPerformer(ctx context.Context, qb models.ImageUpdater, i *models.Image, performerID int) error {
|
2023-09-11 02:24:15 +00:00
|
|
|
imagePartial := models.NewImagePartial()
|
|
|
|
imagePartial.PerformerIDs = &models.UpdateIDs{
|
|
|
|
IDs: []int{performerID},
|
|
|
|
Mode: models.RelationshipUpdateModeAdd,
|
|
|
|
}
|
|
|
|
_, err := qb.UpdatePartial(ctx, i.ID, imagePartial)
|
2022-08-12 02:21:46 +00:00
|
|
|
return err
|
2021-05-03 03:09:46 +00:00
|
|
|
}
|
|
|
|
|
2023-09-01 00:39:29 +00:00
|
|
|
func AddTag(ctx context.Context, qb models.ImageUpdater, i *models.Image, tagID int) error {
|
2023-09-11 02:24:15 +00:00
|
|
|
imagePartial := models.NewImagePartial()
|
|
|
|
imagePartial.TagIDs = &models.UpdateIDs{
|
|
|
|
IDs: []int{tagID},
|
|
|
|
Mode: models.RelationshipUpdateModeAdd,
|
|
|
|
}
|
|
|
|
_, err := qb.UpdatePartial(ctx, i.ID, imagePartial)
|
2022-08-12 02:21:46 +00:00
|
|
|
return err
|
2021-05-03 03:09:46 +00:00
|
|
|
}
|