[英]search inside a list in dynamodb using nodejs
我正在一個項目上,我們正在使用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) {}
誰能幫助我完成這項工作,謝謝
我相信您不能同時查詢兩個索引。 您可以將查詢更改為掃描-但這會比較慢,因為它將為每個查詢掃描整個表-或者您可以僅查詢一個索引。 我會查詢您認為將返回最少結果數(可能是電子郵件)的索引,然后通過shop_id在您的nodejs代碼中過濾結果。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.