Restructure data layer (#2532)

* Add new txn manager interface
* Add txn management to sqlite
* Rename get to getByID
* Add contexts to repository methods
* Update query builders
* Add context to reader writer interfaces
* Use repository in resolver
* Tighten interfaces
* Tighten interfaces in dlna
* Tighten interfaces in match package
* Tighten interfaces in scraper package
* Tighten interfaces in scan code
* Tighten interfaces on autotag package
* Remove ReaderWriter usage
* Merge database package into sqlite
This commit is contained in:
WithoutPants
2022-05-19 17:49:32 +10:00
parent 7b5bd80515
commit 964b559309
244 changed files with 7377 additions and 6699 deletions

View File

@@ -1,5 +1,7 @@
package models
import "context"
type StudioFilterType struct {
And *StudioFilterType `json:"AND"`
Or *StudioFilterType `json:"OR"`
@@ -29,32 +31,32 @@ type StudioFilterType struct {
}
type StudioReader interface {
Find(id int) (*Studio, error)
FindMany(ids []int) ([]*Studio, error)
FindChildren(id int) ([]*Studio, error)
FindByName(name string, nocase bool) (*Studio, error)
FindByStashID(stashID StashID) ([]*Studio, error)
Count() (int, error)
All() ([]*Studio, error)
Find(ctx context.Context, id int) (*Studio, error)
FindMany(ctx context.Context, ids []int) ([]*Studio, error)
FindChildren(ctx context.Context, id int) ([]*Studio, error)
FindByName(ctx context.Context, name string, nocase bool) (*Studio, error)
FindByStashID(ctx context.Context, stashID StashID) ([]*Studio, error)
Count(ctx context.Context) (int, error)
All(ctx context.Context) ([]*Studio, error)
// TODO - this interface is temporary until the filter schema can fully
// support the query needed
QueryForAutoTag(words []string) ([]*Studio, error)
Query(studioFilter *StudioFilterType, findFilter *FindFilterType) ([]*Studio, int, error)
GetImage(studioID int) ([]byte, error)
HasImage(studioID int) (bool, error)
GetStashIDs(studioID int) ([]*StashID, error)
GetAliases(studioID int) ([]string, error)
QueryForAutoTag(ctx context.Context, words []string) ([]*Studio, error)
Query(ctx context.Context, studioFilter *StudioFilterType, findFilter *FindFilterType) ([]*Studio, int, error)
GetImage(ctx context.Context, studioID int) ([]byte, error)
HasImage(ctx context.Context, studioID int) (bool, error)
GetStashIDs(ctx context.Context, studioID int) ([]*StashID, error)
GetAliases(ctx context.Context, studioID int) ([]string, error)
}
type StudioWriter interface {
Create(newStudio Studio) (*Studio, error)
Update(updatedStudio StudioPartial) (*Studio, error)
UpdateFull(updatedStudio Studio) (*Studio, error)
Destroy(id int) error
UpdateImage(studioID int, image []byte) error
DestroyImage(studioID int) error
UpdateStashIDs(studioID int, stashIDs []StashID) error
UpdateAliases(studioID int, aliases []string) error
Create(ctx context.Context, newStudio Studio) (*Studio, error)
Update(ctx context.Context, updatedStudio StudioPartial) (*Studio, error)
UpdateFull(ctx context.Context, updatedStudio Studio) (*Studio, error)
Destroy(ctx context.Context, id int) error
UpdateImage(ctx context.Context, studioID int, image []byte) error
DestroyImage(ctx context.Context, studioID int) error
UpdateStashIDs(ctx context.Context, studioID int, stashIDs []StashID) error
UpdateAliases(ctx context.Context, studioID int, aliases []string) error
}
type StudioReaderWriter interface {