我正在尝试根据2个值获得结果,
取:
identificatorFilter := expression.Name("identificator").Equal(expression.Value(*netAuth.Identificator))
typeFilter := expression.Name("type").Equal(expression.Value(netAuth.Type))
expr, err := expression.NewBuilder().WithFilter(identificatorFilter).WithFilter(typeFilter).Build()
if err != nil {
return response.SimpleResponse{
StatusCode: common.InternalServerError,
}, nil
}
// Read from DynamoDB
input := &dynamodb.QueryInput{
ExpressionAttributeNames: expr.Names(),
ExpressionAttributeValues: expr.Values(),
FilterExpression: expr.Filter(),
ProjectionExpression: expr.Projection(),
TableName: aws.String(account.Table),
}
result, _ := database.Query(input)
结果为0。
type NetAuth struct {
Identificator *string `json:"identificator"`
Password *string `json:"password"`
DeviceID *string `json:"deviceId"`
Type int `json:"type"`
}
我的要求:
{
"identificator": "meh@asd.das",
"password": "DbmMGH4UU9REBB1dEBfTIOYu63S79BiG3ZVcd3zwHsxesX6vtB",
"deviceId": "deviceId",
"type": 0
}
我的数据库包含:
{
"created_at": {
"S": "2018-05-01T20:01:21.180441941Z"
},
"password": {
"S": "da6369cdef0c0464796a734162c6fc67e143a367a754c0236ee9913abb2b2083fc2a71cd16fa10a0232ad667416ed5460b04f367b597331ed26d349452d2aff8"
},
"id": {
"S": "36pmlEm4fbh7HWavLYgaPHXmQ1xv234qWE24TaHCFta65dZFmr"
},
"type": {
"N": "0"
},
"expiry_date": {
"NULL": true
},
"salt": {
"NULL": true
},
"updated_at": {
"S": "2018-05-01T20:01:21.180442027Z"
},
"level": {
"N": "0"
},
"qr_key": {
"NULL": true
},
"identificator": {
"S": "meh@asd.das"
}
}
我尝试删除typeFilter,但它不起作用。 我试图以某种方式显示“查询”,但我找不到方法。
我来自Rdbms所以请原谅我,如果这是愚蠢的错误。
答案 0 :(得分:0)
我向LogLevel: aws.LogLevel(aws.LogDebugWithHTTPBody)
添加了aws.Config
,问题是我选择了错误的列并使用查询而不是扫描(查询只能用于主键)
感谢@Adrian提出这个想法。