Delete a single row from a Tablestore table by calling `deleteRow` in the Node.js SDK. Specify the primary key of the row and a deletion condition.
Prerequisites
Method
deleteRow: function deleteRow(params, callback)Examples
The following code deletes the row with the primary key value 'row1' from the test_table table.
var params = {
tableName: 'test_table',
// The primary key information.
primaryKey: [{ 'id': 'row1' }],
// Set a condition for the deletion. TableStore.RowExistenceExpectation.IGNORE skips the row existence check.
condition: new TableStore.Condition(TableStore.RowExistenceExpectation.IGNORE, null)
};
client.deleteRow(params, function (err, data) {
if (err) {
console.log('Delete row failed with error: ', err);
return;
}
console.log('RequestId: ', data.RequestId);
console.log('Read CU Cost: ', data.consumed.capacityUnit.read);
console.log('Write CU Cost: ', data.consumed.capacityUnit.write);
});