gpt4 book ai didi

node.js - 动态模块 : query with hash key only

转载 作者:搜寻专家 更新时间:2023-10-31 22:42:59 25 4
gpt4 key购买 nike

我有这张表:

  • DomainId 字符串 HashKey
  • EmailId 字符串 RangeKey

我想知道是否可以仅使用 HashKey 查询此表,如下所示:

var AWS = require("aws-sdk");   
var client = new AWS.DynamoDB.DocumentClient();
var dm = 'infodinamica.cl';

//Set params
var params = {
TableName : 'table-name',
KeyConditionExpression: "DomainId = :dm",
ExpressionAttributeValues: {
":dm": dm
},
Select: 'COUNT'
};

client.query(params, (err, data) => {
if(err)
console.log(JSON.stringify(err, null, 2));
else
console.log(JSON.stringify(data, null, 2));
}

ps:注意这张表有HashKey和RangeKey。

最佳答案

是的,仅使用 query API 就可以使用 Hash Key 查询数据。

Use the KeyConditionExpression parameter to provide a specific value for the partition key. The Query operation will return all of the items from the table or index with that partition key value. You can optionally narrow the scope of the Query operation by specifying a sort key value and a comparison operator in KeyConditionExpression. You can use the ScanIndexForward parameter to get results in forward or reverse order, by sort key.

关于node.js - 动态模块 : query with hash key only,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40697913/

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