Skip to content

Commit

Permalink
Merge pull request #48 from twharmon/outpu
Browse files Browse the repository at this point in the history
Add output option to Scan as experiment
  • Loading branch information
twharmon authored Jul 22, 2023
2 parents 2e4c43f + 3c2fd7e commit 05c61d9
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@ import (
// Scan represents a Scan operation.
type Scan struct {
input *dynamodb.ScanInput
output *ScanOutput
dynago *Dynago
items interface{}
err error
}

// ScanOutput represents the output of a scan command.
type ScanOutput struct {
LastEvaluatedKey map[string]*dynamodb.AttributeValue
}

// Scan returns a Scan operation.
func (d *Dynago) Scan(items interface{}) *Scan {
return &Scan{
Expand Down Expand Up @@ -115,6 +121,11 @@ func (q *Scan) ExpressionAttributeName(name string, sub string) *Scan {
return q
}

func (q *Scan) Output(output *ScanOutput) *Scan {
q.output = output
return q
}

// Exec executes the operation.
func (q *Scan) Exec() error {
rv := reflect.ValueOf(q.items)
Expand All @@ -129,6 +140,9 @@ func (q *Scan) Exec() error {
if err != nil {
return fmt.Errorf("d.ddb.GetItem: %w", err)
}
if q.output != nil {
q.output.LastEvaluatedKey = output.LastEvaluatedKey
}
rt := reflect.TypeOf(q.items)
for rt.Kind() == reflect.Pointer {
rt = rt.Elem()
Expand Down

0 comments on commit 05c61d9

Please sign in to comment.