feat: demo flags (#1084)

This commit is contained in:
Jonas Plum
2024-07-21 04:07:23 +02:00
committed by GitHub
parent 91429effe2
commit a9e885598c
16 changed files with 217 additions and 108 deletions
+18
View File
@@ -3,6 +3,7 @@ package app
import (
"slices"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/core"
"github.com/pocketbase/pocketbase/models"
"github.com/spf13/cobra"
@@ -10,6 +11,23 @@ import (
"github.com/SecurityBrewery/catalyst/migrations"
)
func HasFlag(app core.App, flag string) bool {
records, err := app.Dao().FindRecordsByExpr(migrations.FeatureCollectionName, dbx.HashExp{"name": flag})
if err != nil {
app.Logger().Error(err.Error())
return false
}
for _, r := range records {
if r.GetString("name") == flag {
return true
}
}
return false
}
func Flags(app core.App) ([]string, error) {
records, err := app.Dao().FindRecordsByExpr(migrations.FeatureCollectionName)
if err != nil {