使用 DynamoDB.Client.Scan(),如何检索其中一个属性不为空的所有记录?

With DynamoDB.Client.Scan(), how do I retrieve all records where one attribute is not null?

使用 DynamoDB.Client.Scan(),如何检索其中一个属性不为空的所有记录?

类似于:

res = db.scan({
    table_name: "Records", 
    filter_expression: "Fiction != :fiction", 
    expression_attribute_values: { 
        ":fiction" => nil
    }
})

当然不行

如果要查找现有值,应使用 attribute_exists 关键字,请参阅 the documentation

filter_expression: "attribute_exists(Fiction)"

此外,您使用了错误的比较器。 DynamoDB 使用 <> 而不是 != 进行不等式断言。 See documentation