gpt4 book ai didi

node.js - 如何查询dynamoDb表属性(不是分区键或排序键)?

转载 作者:太空宇宙 更新时间:2023-11-04 01:47:06 25 4
gpt4 key购买 nike

我有一张 table ,上面有:

userId(partition key) postId(sort key) category

我想显示按类别过滤的所有项目?

我该怎么做?

我的尝试

    const params = {
TableName: "posts_reddit",

KeyConditionExpression: "userId = :userId",
FilterExpression: "category: category",
ExpressionAttributeValues: {

":userId": event.requestContext.identity.cognitoIdentityId,
":category": "engineering"
}
};

最佳答案

您在过滤表达式中漏掉了一个冒号,它应该是:

“FilterExpression:”类别::类别”

ExpressionAttributeValues 的结构也不正确,您必须提供要作为参数传递的类型。请参阅 scan operation 中的以太示例文档。

关于node.js - 如何查询dynamoDb表属性(不是分区键或排序键)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51033253/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com