diff options
author | Gabriel Arakaki Giovanini <mail@gabrielgio.me> | 2023-06-26 22:26:10 +0200 |
---|---|---|
committer | Gabriel Arakaki Giovanini <mail@gabrielgio.me> | 2023-06-26 22:40:16 +0200 |
commit | 4d930c0c8cb585979798fac2bb254f991faa62fb (patch) | |
tree | 0c33e0e0f2a2f47b0f64843f7d9a3eb299abb260 /pkg/database/sql/user.go | |
parent | d4e1ca3a48e74573df6965ceee217e119ff899ae (diff) | |
download | lens-4d930c0c8cb585979798fac2bb254f991faa62fb.tar.gz lens-4d930c0c8cb585979798fac2bb254f991faa62fb.tar.bz2 lens-4d930c0c8cb585979798fac2bb254f991faa62fb.zip |
feat: Add initial user setup
Diffstat (limited to 'pkg/database/sql/user.go')
-rw-r--r-- | pkg/database/sql/user.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/pkg/database/sql/user.go b/pkg/database/sql/user.go index 2d74162..a02b67b 100644 --- a/pkg/database/sql/user.go +++ b/pkg/database/sql/user.go @@ -187,3 +187,18 @@ func (self *UserRepository) Delete(ctx context.Context, id uint) error { } return nil } + +func (u *UserRepository) Any(ctx context.Context) (bool, error) { + var exists bool + result := u.db. + WithContext(ctx). + Model(&User{}). + Select("count(id) > 0"). + Find(&exists) + + if result.Error != nil { + return false, result.Error + } + + return exists, nil +} |