TableName: people
id | name | age | a place
id_1 | A | 23 | New Zealand
id_2 | B | 12 | India
id_3 | C | 26 | Singapore
id_4 | D | 30 | Turkey
: id → hash and age → range
Question 1
I'm trying to fulfill the request: "Choose * from people, age> 25" I can get it to work with queries such as "Choose age from people where id = id_1 and age> 25", which is not what I need, just you need to select all the values.
And if I don't need age to be a range index, how can I change the query parameters to just return a list of records that meet the criteria: age> 25?
Question 2
AWS , 23 24-41.
: Query Error: ValidationException: KeyConditions KeyConditionExpression. : 400, : []
KeyConditions/KeyConditionsExpressions? , , ?
func queryDynamo() {
log.Println("Enter queryDynamo")
svc := dynamodb.New(nil)
params := &dynamodb.QueryInput{
TableName: aws.String("people"),
Limit: aws.Long(3),
ExpressionAttributeValues: map[string]*dynamodb.AttributeValue{
":v_age": {
N: aws.String("25"),
},
":v_ID": {
S: aws.String("NULL"),
},
},
FilterExpression: aws.String("age >= :v_age"),
KeyConditions: map[string]*dynamodb.Condition{
"age": {
ComparisonOperator: aws.String("GT"),
AttributeValueList: []*dynamodb.AttributeValue{
{
N: aws.String("25"),
},
},
},
"id": {
ComparisonOperator: aws.String("EQ"),
},
},
Select: aws.String("ALL_ATTRIBUTES"),
ScanIndexForward: aws.Boolean(true),
}
resp, err := svc.Query(params)
if err != nil {
log.Println("Query Error: ", err.Error())
}
log.Println(awsutil.StringValue(resp))
}