Skip to content

Commit

Permalink
✨ only expose the query when asked to
Browse files Browse the repository at this point in the history
  • Loading branch information
acidjazz committed Jul 28, 2023
1 parent cfb77b9 commit 0b18fa3
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions aws/dynamo.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ import (
)

type DynamoIndexQuery struct {
Region string
Table string
Wheres DynamoIndexWheres
OrderField string
Direction string
SetLimit *int32
Region string
Table string
Wheres DynamoIndexWheres
OrderField string
Direction string
SetLimit *int32
ExposeQuery bool
}

type DynamoIndexWhere struct {
Expand Down Expand Up @@ -43,6 +44,11 @@ func DynamoIndex(region string, table string) DynamoIndexQuery {
return query
}

func (q DynamoIndexQuery) ShowQuery(value bool) DynamoIndexQuery {
q.ExposeQuery = value
return q
}

func (q DynamoIndexQuery) WhereStr(field string, value string) DynamoIndexQuery {
q.Wheres.Add(field, "string", value)
return q
Expand Down Expand Up @@ -122,7 +128,9 @@ func (q DynamoIndexQuery) Get(out interface{}) (*DynamoIndexResults, error) {
var results DynamoIndexResults
results.Items = out
results.NextToken = p.NextToken
results.Query = &query
if q.ExposeQuery {
results.Query = &query
}

return &results, nil
}
Expand Down

0 comments on commit 0b18fa3

Please sign in to comment.