亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

AWS dynamoDb 分頁限制

AWS dynamoDb 分頁限制

Go
精慕HU 2022-06-27 14:53:57
我正在嘗試對 dynamoDb 中創建的表中的條目進行分頁是否有檢查表項是否已超出。例如,如果我調用從表中獲取項目,我會收到以下錯誤PANIC: runtime error: invalid memory address or nil pointer dereferencegoroutine 51 [running]:github.com/urfave/negroni.(*Recovery).ServeHTTP.func1(0xdfae028, 0xc000186028, 0xc0002162d0, 0xc000154200)    /Users/hammadali/go/pkg/mod/github.com/urfave/[email protected]/recovery.go:159 +0xcbpanic(0x498ea20, 0x51f4410)    /usr/local/Cellar/go/1.14.5/libexec/src/runtime/panic.go:969 +0x166github.com/prohousing-as/ph-supplier-service/application.(*SupplierService).GetAllSuppliers(0xc0002cc300, 0xc00002a270, 0x24, 0xbb8, 0xc0004403e0, 0x0, 0x0)    /Users/hammadali/source/ph-supplier-service/application/supplier_service.go:41 +0x330github.com/prohousing-as/ph-supplier-service/ui.(*SupplierController).GetAllSupplier(0xc000526ed0, 0xdfae028, 0xc000186028, 0xc0003be300)    /Users/hammadali/source/ph-supplier-service/ui/supplier_controller.go:40 +0x139net/http.HandlerFunc.ServeHTTP(0xc000527170, 0xdfae028, 0xc000186028, 0xc0003be300)    /usr/local/Cellar/go/1.14.5/libexec/src/net/http/server.go:2041 +0x44github.com/gorilla/mux.(*Router).ServeHTTP(0xc0002e40c0, 0xdfae028, 0xc000186028, 0xc0003be100)    /Users/hammadali/go/pkg/mod/github.com/gorilla/[email protected]/mux.go:210 +0xe2獲取所有項目的函數// fetches the items from dynamoDb and stores it in resres, err := s.SupplierRepo.GetAllSupplier(uuid, limit)    if err != nil {        fmt.Println("from application: ", err)        return nil, err    }    item := &domain.SupplierTableItems{}    all := &domain.AllSupplierItems{}    // Looping over the result and appending it on the list    for _, i := range res.Items {        err = dynamodbattribute.UnmarshalMap(i, item)        all.Collection = append(all.Collection, *item)        if err != nil {            fmt.Println(err)        }    }    // storing lastEvaluatedKey for pagination    all.LastEvaluatedKey = *res.LastEvaluatedKey["uuid"].S    return all, nil無論如何要檢查為獲取項目所做的調用是否超過了表條目并僅提供剩余的條目數。
查看完整描述

1 回答

?
一只斗牛犬

TA貢獻1784條經驗 獲得超2個贊

您的錯誤與 DynamoDB 的分頁沒有太大關系,您只是試圖訪問不存在的東西,在某個地方/Users/hammadali/source/ph-supplier-service/application/supplier_service.go:41

以其他方式回答您的問題:是的,DynamoDB 會告訴您何時完成分頁。從文檔

  • 如果結果包含 LastEvaluatedKey 元素并且它不為空,請繼續執行步驟 2。

  • 如果結果中沒有 LastEvaluatedKey,則沒有要檢索的項目。


查看完整回答
反對 回復 2022-06-27
  • 1 回答
  • 0 關注
  • 131 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號