This topic describes how to update table configurations using Tablestore SDK for Node.js.
Prerequisites
Method description
updateTable: function describeTable(params, callback)
Note
When you call the
updateTable()
method, you must set tableOptions.When you set tableOptions, you must set at least one of the following parameters: timeToLive, maxVersions, maxTimeDeviation, or allowUpdate.
Sample code
The following sample code demonstrates how to modify the configurations of the test_table table.
var params = {
tableName: 'test_table',
tableOptions: {
// Set the TTL to 86400 seconds
timeToLive: 86400,
// Set the maximum number of versions
maxVersions: 3,
// Set the maximum version offset to 86400 seconds
maxTimeDeviation: 86400,
// Specify whether to allow updates
allowUpdate: false
},
// Set the reserved read throughput to 0 CUs and the reserved write throughput to 0 CUs (Only high-performance instances in CU mode support setting non-zero values for reserved read and write throughput)
reservedThroughput: {
capacityUnit: {
read: 0,
write: 0
}
},
// Enable Stream and set the Stream expiration time to 7 days
streamSpecification: {
enableStream: true,
expirationTime: 168
}
};
client.updateTable(params, function (err, data) {
if (err) {
console.error('error:', err);
return;
}
console.log('success:', data);
});