我正在使用dynamoDB本地。我想創建一個具有6個屬性的表格,其中只有一個是key
。我怎麼做?在keySchema
中指定關鍵屬性,並在AttributeDefinitions
中指定所有屬性?node.js:如何在創建表時在DynamoDB中添加非鍵屬性?
var params = {
TableName : "Movies",
KeySchema: [
{ AttributeName: "year", KeyType: "HASH"}, //Partition key
],
AttributeDefinitions: [
{ AttributeName: "year", AttributeType: "N" },
{ AttributeName: "title", AttributeType: "S" }
],
ProvisionedThroughput: {
ReadCapacityUnits: 10,
WriteCapacityUnits: 10
}
};
dynamodb.createTable(params, 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));
}
});