Hapus satu baris dari tabel Tablestore dengan memanggil deleteRow pada SDK Node.js. Tentukan kunci primer baris tersebut dan kondisi penghapusan.
Prasyarat
Metode
deleteRow: function deleteRow(params, callback)
Contoh
Kode berikut menghapus baris dengan nilai kunci primer row1 dari tabel test_table.
var params = {
tableName: 'test_table',
// Informasi kunci primer.
primaryKey: [{ 'id': 'row1' }],
// Tetapkan kondisi untuk penghapusan. TableStore.RowExistenceExpectation.IGNORE melewati pemeriksaan keberadaan baris.
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);
});