本文整理汇总了Golang中github.com/aws/aws-sdk-go/service/dynamodb.DynamoDB.Scan方法的典型用法代码示例。如果您正苦于以下问题:Golang DynamoDB.Scan方法的具体用法?Golang DynamoDB.Scan怎么用?Golang DynamoDB.Scan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/aws/aws-sdk-go/service/dynamodb.DynamoDB
的用法示例。
在下文中一共展示了DynamoDB.Scan方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: CheckRowCount
// CheckRowCount returns the number of records in a table.
func CheckRowCount(db *dynamodb.DynamoDB, tableName string) int {
resp, err := db.Scan(&dynamodb.ScanInput{
TableName: aws.String(tableName),
Select: aws.String(dynamodb.SelectCount),
})
if err != nil {
return -1
}
return int(*resp.Count)
}
示例2: CheckRows
// CheckRows returns a Row accessor for every row in a table. The order of rows
// is unspecified. If an error occurs, the rows will be nil. The returned
// ValueDefiner can be used to define access to custom types across all rows.
func CheckRows(db *dynamodb.DynamoDB, tableName string) ([]Row, ValueDefiner) {
resp, err := db.Scan(&dynamodb.ScanInput{
TableName: aws.String(tableName),
})
if err != nil {
return nil, nil
}
vd := newValueDefiner()
rows := make([]Row, len(resp.Items))
for i, item := range resp.Items {
reader := valueReader{item, vd}
rows[i] = Row{reader}
}
return rows, vd
}
示例3: handleList
func handleList() {
var client *dynamodb.DynamoDB = dbutil.CreateDynamoDBClient()
params := &dynamodb.ScanInput{
TableName: aws.String(ddl.AdminTableName),
AttributesToGet: []*string{
aws.String("AdminID"),
},
}
resp, err := client.Scan(params)
if err != nil {
fmt.Println(err.Error())
return
}
fmt.Println(resp)
}