Exclua uma linha de uma tabela de dados do Tablestore com o SDK para Go.
Pré-requisitos
Método
func (tableStoreClient *TableStoreClient) DeleteRow(request *DeleteRowRequest) (*DeleteRowResponse, error)
Exemplo
O exemplo a seguir exclui a linha com valor de chave primária 'row1' da tabela 'test_table'.
func DeleteRowSample(client *tablestore.TableStoreClient) {
// Build the primary key.
deletePk := new(tablestore.PrimaryKey)
deletePk.AddPrimaryKeyColumn("id", "row1")
// Build the DeleteRowChange for the target row.
deleteRowChange := new(tablestore.DeleteRowChange)
deleteRowChange.TableName = "test_table"
deleteRowChange.PrimaryKey = deletePk
// A delete condition is required. RowExistenceExpectation_IGNORE skips the row existence check.
deleteRowChange.SetCondition(tablestore.RowExistenceExpectation_IGNORE)
// Invoke DeleteRow to delete the row.
deleteRowReq := new(tablestore.DeleteRowRequest)
deleteRowReq.DeleteRowChange = deleteRowChange
response, err := client.DeleteRow(deleteRowReq)
if err != nil {
fmt.Println("Delete row failed with error: ", err)
} else {
fmt.Printf("RequestId: %s \n", response.RequestId)
fmt.Printf("Read CU Cost: %d \n", response.ConsumedCapacityUnit.Read)
fmt.Printf("Write CU Cost: %d \n", response.ConsumedCapacityUnit.Write)
}
}