Amazon web services 使用Lamda函数(Python/Node)查找DynomoDB表项中的对象数
我是AWS世界的新手,我需要从DynamoDB表中查找数据计数。 我的桌子结构是这样的Amazon web services 使用Lamda函数(Python/Node)查找DynomoDB表项中的对象数,amazon-web-services,aws-lambda,amazon-dynamodb,Amazon Web Services,Aws Lambda,Amazon Dynamodb,我是AWS世界的新手,我需要从DynamoDB表中查找数据计数。 我的桌子结构是这样的 它有两个项目(MySQL中的列),比如A和B A-存储(主分区键)用户ID B-存储用户配置文件,与用户ID关联的配置文件数 假设A包含一个用户ID3435,并且它有3个配置文件({“21btet3”、“3sd4”、“adf11}) 我的要求是将计数3作为JSON以以下格式输出: 如何设置扫描此查询的参数? 有人能帮忙吗 DynamoDb是NoSQL,因此在查询方面有一些限制 数据。在您的情况下,您必须像下面
您不应该定期进行全表扫描。 如果您的需求是经常获取此计数,那么您应该在新记录插入dynamodb时订阅并更新计数。这将确保
def ScanDynamoData(lastEvalutedKey):
table = boto3.resource("dynamodb", "eu-west-1").Table('TableName') #Add your region and table name
if lastEvalutedKey:
return table.scan(
ExclusiveStartKey=lastEvalutedKey
)
else:
return table.scan()
response = ScanDynamoData(None);
totalUserIds = response["Count"]
#In response you will get the json of entire table you can count userid and profiles here
while "LastEvaluatedKey" in response:
response = ScanDynamoData(response["LastEvaluatedKey"])
totalUserIds += response["Count"]
#Add counts here also