Delete rows with mutate

Delete rows using mutate.

Code sample

C++

To learn how to install and use the client library for Bigtable, see Bigtable client libraries.

To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

namespace cbt = ::google::cloud::bigtable;
[](cbt::Table table, std::vector<std::string> const& keys) {
  cbt::BulkMutation mutation;
  for (auto const& row_key : keys) {
    mutation.emplace_back(
        cbt::SingleRowMutation(row_key, cbt::DeleteFromRow()));
  }
  std::vector<cbt::FailedMutation> failures =
      table.BulkApply(std::move(mutation));
  if (failures.empty()) {
    std::cout << "All rows successfully deleted\n";
    return;
  }
  std::cerr << "The following mutations failed:\n";
  for (auto const& f : failures) {
    std::cerr << "index[" << f.original_index() << "]=" << f.status() << "\n";
  }
}

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.