【发布时间】:2016-01-08 08:10:00
【问题描述】:
我正在尝试使用 nodejs 内的 javascript SDK 创建具有全局二级索引的表:
var messagesTableParams = {
TableName : "Messages",
KeySchema: [
{ AttributeName: "to", KeyType: "HASH"}, //Partition key
{ AttributeName: "tm", KeyType: "RANGE" } //Sort key
],
AttributeDefinitions: [
{ AttributeName: "to", AttributeType: "N" },
{ AttributeName: "tm", AttributeType: "N" }
],
ProvisionedThroughput: {
ReadCapacityUnits: 10,
WriteCapacityUnits: 10
},
GlobalSecondaryIndexes: [
{
IndexName: 'fr_indx',
KeySchema: [
{ AttributeName: "fr", KeyType: "HASH"}, //Partition key
{ AttributeName: "tm", KeyType: "RANGE" } //Sort key
],
AttributeDefinitions: [
{ AttributeName: "fr", AttributeType: "N" },
{ AttributeName: "tm", AttributeType: "N" }
],
Projection: {
ProjectionType: 'KEYS_ONLY'
},
ProvisionedThroughput: {
ReadCapacityUnits: 10,
WriteCapacityUnits: 10
}
}
]
};
dynamodb.createTable(messagesTableParams, function(err, data) {
if (err) {
console.error("Unable to create table. Error JSON:", JSON.stringify(err, null, 2));
} else {
console.log("Created table. Table description JSON:", JSON.stringify(data, null, 2));
}
});
但我不断收到以下错误,并且未创建表:
无法创建表。错误 JSON:{“消息”:“意外的键 在 params.GlobalSecondaryIndexes[0] 中找到“AttributeDefinitions”",
“代码”:“UnexpectedParameter”,“时间”:“2016-01-07T18:51:11.659Z”}
【问题讨论】:
标签: javascript node.js amazon-web-services amazon-dynamodb