// 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) }
// 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 }
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) }