Skip to content

Commit

Permalink
Add usage of SDK ddb attribute value unmarshaling
Browse files Browse the repository at this point in the history
  • Loading branch information
jrichardpfs committed Feb 14, 2022
1 parent 33006f1 commit a5bbf65
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions example/service/dynamodb/scanItems/scanItems.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"flag"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue"
"github.com/aws/aws-sdk-go-v2/service/dynamodb"
"log"
)
Expand All @@ -19,6 +20,11 @@ func init() {
flag.StringVar(&region, "region", "", "The `region` of your AWS project.")
}

type Record struct {
ID string
URLs []string
}

func main() {
flag.Parse()
if len(tableName) == 0 {
Expand All @@ -44,10 +50,13 @@ func main() {
if err != nil {
log.Fatalf("Query API call failed: %s", err)
}
for _, i := range scan.Items {
for k, v := range i {
log.Printf("item %s: %v", k, v)
}
var records []Record
err = attributevalue.UnmarshalListOfMaps(scan.Items, &records)
if err != nil {
return
}
for _, record := range records {
log.Printf("Record : %v", record)
}

}

0 comments on commit a5bbf65

Please sign in to comment.