mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 21:37:32 +00:00
fix: improve db call when only count is required (on views) (#2769)
* fix: improve db call when only count is required (old views) * Update query.go
This commit is contained in:
@@ -2,11 +2,12 @@ package repository
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/caos/zitadel/internal/domain"
|
||||
|
||||
caos_errs "github.com/caos/zitadel/internal/errors"
|
||||
"github.com/jinzhu/gorm"
|
||||
"github.com/lib/pq"
|
||||
|
||||
"github.com/caos/zitadel/internal/domain"
|
||||
caos_errs "github.com/caos/zitadel/internal/errors"
|
||||
)
|
||||
|
||||
type SearchRequest interface {
|
||||
@@ -48,6 +49,9 @@ func PrepareSearchQuery(table string, request SearchRequest) func(db *gorm.DB, r
|
||||
}
|
||||
|
||||
query = query.Count(&count)
|
||||
if res == nil {
|
||||
return count, nil
|
||||
}
|
||||
if request.GetLimit() != 0 {
|
||||
query = query.Limit(request.GetLimit())
|
||||
}
|
||||
|
Reference in New Issue
Block a user