Skip to content

Commit

Permalink
refactor(api): use GORM API instead of raw query
Browse files Browse the repository at this point in the history
  • Loading branch information
bouassaba committed Aug 26, 2024
1 parent 4c43557 commit c4740f4
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions api/repo/group_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,17 +178,12 @@ func (repo *groupRepo) Find(id string) (model.Group, error) {
}

func (repo *groupRepo) Count() (int64, error) {
type Result struct {
Result int64
}
var res Result
db := repo.db.
Raw("SELECT count(*) as result FROM \"group\"").
Scan(&res)
var count int64
db := repo.db.Model(&groupEntity{}).Count(&count)
if db.Error != nil {
return 0, db.Error
}
return res.Result, nil
return count, nil
}

func (repo *groupRepo) GetIDsByFile(fileID string) ([]string, error) {
Expand Down

0 comments on commit c4740f4

Please sign in to comment.