Skip to content

Commit

Permalink
Pass a list of IDs for exact querying (#1288)
Browse files Browse the repository at this point in the history
* feat: pass a list of IDs for exact querying

* feat: support both id and key
  • Loading branch information
GAlexIHU authored Aug 2, 2024
1 parent 782f142 commit 4ded17e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions internal/productcatalog/feature_connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func (f FeatureOrderBy) StrValues() []string {
}

type ListFeaturesParams struct {
IDsOrKeys []string
Namespace string
MeterSlugs []string
IncludeArchived bool
Expand Down
6 changes: 6 additions & 0 deletions internal/productcatalog/postgresadapter/feature.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ func (c *featureDBAdapter) ListFeatures(ctx context.Context, params productcatal
query.Where(db_feature.MeterSlugIn(params.MeterSlugs...))
}

if len(params.IDsOrKeys) > 0 {
for _, idOrKey := range params.IDsOrKeys {
query.Where(db_feature.Or(db_feature.Key(idOrKey), db_feature.ID(idOrKey)))
}
}

if !params.IncludeArchived {
query = query.Where(db_feature.Or(db_feature.ArchivedAtIsNil(), db_feature.ArchivedAtGT(clock.Now())))
}
Expand Down

0 comments on commit 4ded17e

Please sign in to comment.