dousi6303 2016-11-02 09:19
浏览 102
已采纳

如何在aws-sdk-go Dynamodb QueryInput中使用“ BETWEEN”?

I am using aws-sdk-go for dynamodb. I need to collect some items from my DB. The filtering conditions are deviceid: xyz, time >= 10 and time <= 20.

time is the sort key for my db and deviceid is the primary key. I understand I have to use BETWEEN for achieving my goal. My Implementations are not successful and as follows:

var queryInput = &dynamodb.QueryInput{
    TableName: aws.String(dbName),
    KeyConditions: map[string]*dynamodb.Condition{
        "deviceid": {
            ComparisonOperator: aws.String("EQ"),
            AttributeValueList: []*dynamodb.AttributeValue{
                {
                    S: aws.String("xyz"),
                },
            },
        },
        "time": {
            ComparisonOperator: aws.String("BETWEEN"),
            AttributeValueList: []*dynamodb.AttributeValue{
                {
                    N: aws.String("10"),
                    N: aws.String("20"),
                },
            },

        },
    },
}

What are the mistakes I made here?

  • 写回答

1条回答 默认 最新

  • duan246558 2016-11-02 13:45
    关注

    The time value should be given as mentioned below:-

    "time": {
                ComparisonOperator: aws.String("BETWEEN"),
                AttributeValueList: []*dynamodb.AttributeValue{
                    {
                        N: aws.String("10"),                        
                    },
                    {
                        N: aws.String("20"),                        
                    },
                },
            },
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 我这模型写的不对吗?为什么lingo解出来的下面影子价格这一溜少一个变量
  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波