Documentation
¶
Index ¶
- Variables
- func FindResourceIDByAlias(ctx context.Context, db bun.IDB, cfg ResourceConfig, name string, ...) (int, error)
- func TransferAliasesOnMerge(ctx context.Context, db bun.IDB, cfg ResourceConfig, sourceID, targetID int) error
- type ResourceConfig
- type Service
- func (svc *Service) AddAlias(ctx context.Context, cfg ResourceConfig, resourceID int, name string, ...) error
- func (svc *Service) ListAliases(ctx context.Context, cfg ResourceConfig, resourceID int) ([]string, error)
- func (svc *Service) RemoveAlias(ctx context.Context, cfg ResourceConfig, resourceID int, name string) error
- func (svc *Service) RemoveAllAliases(ctx context.Context, cfg ResourceConfig, resourceID int) error
- func (svc *Service) SyncAliases(ctx context.Context, cfg ResourceConfig, resourceID int, libraryID int, ...) error
Constants ¶
This section is empty.
Variables ¶
var ( GenreConfig = ResourceConfig{ AliasTable: "genre_aliases", ResourceFK: "genre_id", ResourceTable: "genres", } TagConfig = ResourceConfig{ AliasTable: "tag_aliases", ResourceFK: "tag_id", ResourceTable: "tags", } SeriesConfig = ResourceConfig{ AliasTable: "series_aliases", ResourceFK: "series_id", ResourceTable: "series", } PersonConfig = ResourceConfig{ AliasTable: "person_aliases", ResourceFK: "person_id", ResourceTable: "persons", } PublisherConfig = ResourceConfig{ AliasTable: "publisher_aliases", ResourceFK: "publisher_id", ResourceTable: "publishers", } )
Functions ¶
func FindResourceIDByAlias ¶
func FindResourceIDByAlias(ctx context.Context, db bun.IDB, cfg ResourceConfig, name string, libraryID int) (int, error)
FindResourceIDByAlias looks up a resource ID by checking alias names (case-insensitive). Returns the resource ID if found, or sql.ErrNoRows if no alias matches.
func TransferAliasesOnMerge ¶
func TransferAliasesOnMerge(ctx context.Context, db bun.IDB, cfg ResourceConfig, sourceID, targetID int) error
TransferAliasesOnMerge reassigns the source resource's aliases to the target and adds the source's primary name as a new alias of the target, owned by the target's Library. Duplicates (case-insensitive match against the target's primary name or existing aliases) are silently left for CASCADE to clean up when the source is deleted. When the source's name is already an alias of a third resource in the target's Library, that alias stays where it is and the target does not get it, since the alias table allows each name once per Library. Accepts bun.IDB so it works inside a transaction.
Types ¶
type ResourceConfig ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}