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

没有找到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 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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题