gpt4 book ai didi

javascript - 使用nodejs在dynamodb中的列表中搜索

转载 作者:行者123 更新时间:2023-11-30 15:02:57 25 4
gpt4 key购买 nike

我正在做一个项目,我们使用 Dynamodb 作为数据库,我有一个具有这种结构的文档:

{
"shop_id": "hh-delightme",
"shoppers": [
{
"email": "hatim.haffane@gmail.com",
"name": "hatim haffane"
},
{
"email": "xxx.zzz@gmail.com",
"name": "bxdsf sdf sd f"
}
]
},{
"shop_id": "it-delightme",
"shoppers": [
{
"email": "hatim.haffane@gmail.com",
"name": "hatim haffane"
},
{
"email": "xxx.zzz@gmail.com",
"name": "bxdsf sdf sd f"
}
]
}

我有两个索引 shop-id-index 和 email-index ,所以我想做的是让购物者在 shop_id “hh-delightme” 中使用电子邮件“hatim.haffane@gmail.com”

我试过这段代码但没有成功

var params = {
TableName:"shopper",
KeyConditionExpression:"shop_id = :shop_id AND email = :email",
ExpressionAttributeValues: {
":shop_id":store,
":email":email
}

};

docClient.query(params, function(err, data) {}

谁能帮我完成这个,谢谢

最佳答案

我相信你不能同时查询两个索引。您可以将查询更改为扫描——但这会比较慢,因为它会为每个查询扫描整个表——或者您可以只查询一个索引。我会查询您认为会返回最少数量结果的索引,可能是电子邮件,然后在您的 nodejs 代码中按 shop_id 过滤结果。

关于javascript - 使用nodejs在dynamodb中的列表中搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46226774/

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