我正在使用 Node.js
var AWS = require('aws-sdk');
AWS.config.update({
region: "region",
endpoint: "https://dynamodb.region.amazonaws.com"
});
var dynamodb = new AWS.DynamoDB();
var params = {
TableName: "acc_new"
};
dynamodb.describeTable(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(JSON.stringify(data));
});
输出:
{ AttributeDefinitions: [ { AttributeName: 'Id', AttributeType: 'S' } ],
TableName: 'acc_new',
KeySchema: [ { AttributeName: 'Id', KeyType: 'HASH' } ],
ProvisionedThroughput: { ReadCapacityUnits: 5, WriteCapacityUnits: 5 } }
输出仅包含与表关联的键模式(仅哈希和范围键),而不是所有属性。我想获取与表中数据关联的所有属性。
喜欢:
{ AttributeName: 'AccountName', AttributeType: 'S' }
{ AttributeName: 'CreatedBy', AttributeType: 'S' }
...
...
有什么方法可以获取 dynamoDb 表及其所有数据字段的描述。
最佳答案
DynamoDB 是一个 NoSQL 数据库。在创建表时,它并不期望在表中定义所有属性。此外,每个项目都可以有任意数量的非关键属性。只有关键属性在表中的所有项目中是通用的或必需的。
由于上述原因,describe 表无法提供表中存在的所有属性。
关于node.js - 如何获取 aws-dynamoDB 中存在的所有字段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44880707/