mirror of
https://github.com/navidrome/navidrome.git
synced 2026-10-28 22:27:10 +01:00
feat(database): add user_library table and library access methods
Signed-off-by: Deluan <deluan@navidrome.org> # Conflicts: # tests/mock_library_repo.go
This commit is contained in:
parent
3c1e5603d0
commit
40bbae16c4
9 changed files with 533 additions and 6 deletions
|
|
@ -36,6 +36,9 @@ type LibraryRepository interface {
|
|||
StoreMusicFolder() error
|
||||
AddArtist(id int, artistID string) error
|
||||
|
||||
// User-library association methods
|
||||
GetUsersWithLibraryAccess(libraryID int) (Users, error)
|
||||
|
||||
// TODO These methods should be moved to a core service
|
||||
ScanBegin(id int, fullScan bool) error
|
||||
ScanEnd(id int) error
|
||||
|
|
|
|||
|
|
@ -13,6 +13,9 @@ type User struct {
|
|||
CreatedAt time.Time `structs:"created_at" json:"createdAt"`
|
||||
UpdatedAt time.Time `structs:"updated_at" json:"updatedAt"`
|
||||
|
||||
// Library associations (many-to-many relationship)
|
||||
Libraries []Library `structs:"-" json:"libraries,omitempty"`
|
||||
|
||||
// This is only available on the backend, and it is never sent over the wire
|
||||
Password string `structs:"-" json:"-"`
|
||||
// This is used to set or change a password when calling Put. If it is empty, the password is not changed.
|
||||
|
|
@ -35,4 +38,10 @@ type UserRepository interface {
|
|||
FindByUsername(username string) (*User, error)
|
||||
// FindByUsernameWithPassword is the same as above, but also returns the decrypted password
|
||||
FindByUsernameWithPassword(username string) (*User, error)
|
||||
|
||||
// Library association methods
|
||||
GetUserLibraries(userID string) (Libraries, error)
|
||||
SetUserLibraries(userID string, libraryIDs []int) error
|
||||
AddUserLibrary(userID string, libraryID int) error
|
||||
RemoveUserLibrary(userID string, libraryID int) error
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue