Dynamo DB Pages

Dynamo code snippet

Recently got burned because we needed to do a recursive paging through dynamo

var listOfThings []Whatever

err := store.ScanPages(input,
    func (page *dynamodb.ScanOutput, lastPage bool) bool {
        for _, item := range page.Items {
            var whateva Whatever
            if val, ok := item["jval"]; ok {
                err := json.Unmarshal([]byte(*val.S), &whateva)
                if err != nil {
                    return true // its like continue
                }
                listOfThings = append(listOfThings, whateva)
            }
        }
    return !lastPage
})
if err != nil {
    t.Fail()
}

---

updated: 2 October 2021.

to the Index

/ html