doutu1939
2018-05-02 16:10 浏览 33
已采纳

没有找到DynamoDB结果,但有

I am trying to get results based on 2 values,

fetching:

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)

The results are 0.

type NetAuth struct {
    Identificator *string `json:"identificator"`
    Password      *string `json:"password"`
    DeviceID      *string `json:"deviceId"`
    Type          int     `json:"type"`
}

My request:

{
  "identificator": "meh@asd.das",
  "password": "DbmMGH4UU9REBB1dEBfTIOYu63S79BiG3ZVcd3zwHsxesX6vtB",
  "deviceId": "deviceId",
  "type": 0
}

My database contains:

 {
            "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"
            }
        }

I tried removing typeFilter however it does not work. I tried somehow to show the "query" however I cannot find a way.

I am coming from Rdbms so please excuse me if it's stupid mistake.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答 默认 最新

  • 已采纳
    douzai8285 douzai8285 2018-05-02 19:43

    I added: LogLevel: aws.LogLevel(aws.LogDebugWithHTTPBody) to the aws.Config and the problem was that I was selecting wrong column and using query instead of scan (query can be used only for the primary key)

    Thank you @Adrian for the idea which led me to this.

    点赞 评论 复制链接分享

相关推荐