mirror of
https://github.com/stashapp/stash.git
synced 2025-12-06 08:26:00 +01:00
* Load scene relationships on demand * Load image relationships on demand * Load gallery relationships on demand * Add dataloaden * Use dataloaders * Use where in for other find many functions
32 lines
768 B
Go
32 lines
768 B
Go
package image
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/stashapp/stash/pkg/models"
|
|
)
|
|
|
|
type PartialUpdater interface {
|
|
UpdatePartial(ctx context.Context, id int, partial models.ImagePartial) (*models.Image, error)
|
|
}
|
|
|
|
func AddPerformer(ctx context.Context, qb PartialUpdater, i *models.Image, performerID int) error {
|
|
_, err := qb.UpdatePartial(ctx, i.ID, models.ImagePartial{
|
|
PerformerIDs: &models.UpdateIDs{
|
|
IDs: []int{performerID},
|
|
Mode: models.RelationshipUpdateModeAdd,
|
|
},
|
|
})
|
|
|
|
return err
|
|
}
|
|
|
|
func AddTag(ctx context.Context, qb PartialUpdater, i *models.Image, tagID int) error {
|
|
_, err := qb.UpdatePartial(ctx, i.ID, models.ImagePartial{
|
|
TagIDs: &models.UpdateIDs{
|
|
IDs: []int{tagID},
|
|
Mode: models.RelationshipUpdateModeAdd,
|
|
},
|
|
})
|
|
return err
|
|
}
|