Este tema describe cómo actualizar la configuración de tablas mediante el SDK de Tablestore para Node.js.
Requisitos previos
Descripción del método
updateTable: function describeTable(params, callback)
Nota
Al llamar al método
updateTable(), debe establecer tableOptions.Al configurar tableOptions, debe establecer como mínimo uno de los siguientes parámetros: timeToLive, maxVersions, maxTimeDeviation o allowUpdate.
Código de ejemplo
A continuación se muestra un código de ejemplo que demuestra cómo modificar la configuración de la tabla test_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);
});