diff options
Diffstat (limited to 'pkg/database')
-rw-r--r-- | pkg/database/repository/user.go | 1 | ||||
-rw-r--r-- | pkg/database/sql/user.go | 17 |
2 files changed, 18 insertions, 0 deletions
diff --git a/pkg/database/repository/user.go b/pkg/database/repository/user.go index f8bd719..3589007 100644 --- a/pkg/database/repository/user.go +++ b/pkg/database/repository/user.go @@ -27,6 +27,7 @@ type ( UserRepository interface { Get(ctx context.Context, id uint) (*User, error) + GetPathFromUserID(ctx context.Context, id uint) (string, error) List(ctx context.Context) ([]*User, error) Create(ctx context.Context, createUser *CreateUser) (uint, error) Update(ctx context.Context, id uint, updateUser *UpdateUser) error diff --git a/pkg/database/sql/user.go b/pkg/database/sql/user.go index 479a9c5..11718be 100644 --- a/pkg/database/sql/user.go +++ b/pkg/database/sql/user.go @@ -201,3 +201,20 @@ func (u *UserRepository) Any(ctx context.Context) (bool, error) { return exists, nil } + +func (u *UserRepository) GetPathFromUserID(ctx context.Context, id uint) (string, error) { + var userPath string + + result := u.db. + WithContext(ctx). + Model(&User{}). + Select("path"). + Where("id = ?", id). + First(&userPath) + + if result.Error != nil { + return "", result.Error + } + + return userPath, nil +} |