Cette rubrique explique comment mettre à jour les configurations d'une table à l'aide du SDK Tablestore pour Node.js.
Prérequis
Description de la méthode
updateTable: function describeTable(params, callback)
Remarque
Lors de l'appel à la méthode
updateTable(), vous devez définir tableOptions.Lors de la définition de tableOptions, spécifiez au moins l'un des paramètres suivants : timeToLive, maxVersions, maxTimeDeviation ou allowUpdate.
Exemple de code
L'exemple de code suivant montre comment modifier les configurations de la table 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);
});