本文介紹如何通過 Node.js SDK 更新表的配置資訊。
前提條件
方法說明
updateTable: function describeTable(params, callback)
說明
調用
updateTable()
方法時,必須設定tableOptions。設定 tableOptions 時,必須設定timeToLive、maxVersions、maxTimeDeviation、allowUpdate中的至少一項。
範例程式碼
以下範例程式碼用於修改test_table表的配置資訊。
var params = {
tableName: 'test_table',
tableOptions: {
// 設定資料生命週期,單位為秒
timeToLive: 86400,
// 設定最大版本數
maxVersions: 3,
// 設定有效版本偏差,單位為秒
maxTimeDeviation: 86400,
// 設定是否允許更新
allowUpdate: false
},
// 設定預留讀為0CU,預留寫為0CU(僅CU模式高效能執行個體支援設定資料表的預留讀寫輸送量為非零值)
reservedThroughput: {
capacityUnit: {
read: 0,
write: 0
}
},
// 開啟Stream資訊,並設定Stream到期時間為7天
streamSpecification: {
enableStream: true,
expirationTime: 168
}
};
client.updateTable(params, function (err, data) {
if (err) {
console.error('error:', err);
return;
}
console.log('success:', data);
});