【问题标题】:go and dynamo get data from table where field in list and field is not null / field is not emptygo and dynamo 从表中的字段和字段不为空/字段不为空的表中获取数据
【发布时间】:2020-08-21 00:13:41
【问题描述】:

您知道如何使用“列表中的字段”(例如:“输入 ('first','primero','base')”)进行 get 或 delete 调用吗? (请使用 dynamo-goLang。)

以下代码有效:

input := &dynamodb.GetItemInput{
    TableName: aws.String(myTableName),
    Key: map[string]dynamodb.AttributeValue{
        "id": {
            S: aws.String(positionId),
        },
        "type": {
            S: aws.String('first'),
        },
    },
}

但我想从类型列表中获取数据(其中类型在列表中),或者类型不为空或不为空。

我打算在 dynamo-goLang 中做的事情的 sql 示例:

SELECT * FROM myTableName WHERE id = positionId AND type IN ('first','primero','base');

SELECT * FROM myTableName WHERE id = positionId AND type IS NOT NULL;

【问题讨论】:

    标签: amazon-web-services go amazon-dynamodb dynamodb-queries


    【解决方案1】:

    要在指定分区键并希望按排序键过滤的情况下获得多个结果,您需要使用 Query 而不是 GetItem。

    一些资源的例子,因为我的 golang 有点生疏:

    【讨论】:

    • 嗨。分区和哈希键不是一回事吗?您还确定 type 是 OP 案例中的排序键吗?
    • 哎呀,我的意思是排序而不是哈希,太多的 4 个字母单词 :)。我不确定idtype 是分区还是排序,但希望他能澄清我的假设是否不正确。另外,恭喜您获得最近的金 AWS 徽章,感谢您在社区中的所有支持,也许我可以在几年内获得其中一个 :)
    • 没问题,谢谢。你会到达那里。一步一步:-)
    猜你喜欢
    • 2016-06-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多