Skip to content

Instantly share code, notes, and snippets.

@callmehiphop
Last active August 29, 2015 14:24
Show Gist options
  • Save callmehiphop/7849a495cbb5c8deedf9 to your computer and use it in GitHub Desktop.
Save callmehiphop/7849a495cbb5c8deedf9 to your computer and use it in GitHub Desktop.

BigTable

var bigtable = gcloud.bigtable();

getZones

bigtable.getZones(function(err, zones, apiResponse) {});

Zone


getClusters

var zone = bigtable.zone('my-zone');

zone.getClusters(function(err, clusters, apiResponse) {});

Create a cluster

zone.createCluster(clusterOptions, function(err, cluster, apiResponse) {});

Cluster


Get Cluster Metadata

cluster.getMetadata(function (err, metadata, apiResponse) {});

Update Cluster Metadata

cluster.setMetadata(metaData, function(err, metadata, apiResponse) {});

Delete Cluster

cluster.delete(function (err, apiResponse) {});

Undelete Cluster

cluster.restore(function (err, apiResponse) {});

Create a Table

cluster.createTable('my-table', function(err, table, apiResponse) {});
// or
cluster.createTable(tableOptions, function(err, table, apiResponse) {});

Get Prexisting Table (half initialized)

var myTable = cluster.table('my-table');

Get All Tables on Cluster

cluster.getTables(function (err, tables, apiResponse) {});

Table


Get Table Schema

table.getMetadata(function (err, tableSchema, apiResponse) {});

Delete a Table

table.delete(function (err, table, apiResponse) {});

Rename a Table

table.rename('awesome-table', function (err, table, apiResponse) {});

Create a Column Family

table.createFamily('user', function (err, family, apiResponse) {});

Get Pre-existing Family (half initialized)

var userFamily = table.family('user');

Update a Family

userFamily.setMetadata(metaData, function(err, family, apiResponse) {});

Delete a Family

userFamily.delete(function(err, apiResponse) {});

Get Sample Keys

If a callback is not provided a stream will be returned

table.getSampleKeys(function (err, keys, apiResponse) {});

Get Table Rows

If callback is not provided a stream is returned

var rowOptions = {
  prefix: 'com.google.'
};

table.getRows(rowOptions, function(err, rows, apiResponse) {});

Delete Table Rows

rowOptions would be filters used to determine which rows to delete

table.deleteRows(rowOptions, function(err, apiResponse) {});

Create a Row

table.createRow(rowData, function(err, row, apiResponse) {});

Create Multiple Rows

table.createRows([rowData], function(err, rows, apiResponse) {});

Get Specific Row (half initialized)

var myRow = table.row('my-row');

Update a Row

myRow.set('user:name', 'stephen', function(err, row, apiResponse) {});

// or for multiple columns
var rowData = {
  user: { // family
    name: 'stephen', // column
    age: 99 // column
  }
};
myRow.set(rowData, function(err, row, apiResponse) {});

Get Columns From Row

myRow.get(['user:name'], function(err, columns, apiResponse) {});

Delete Columns From Row

myRow.delete(['user:name'], function(err, columns, apiResponse) {});

Delete An Entire Row

myRow.delete(function(err, columns, apiResponse) {});

Target Specific Family From Row

This should not be confused with the Table#family which allows you to update/delete families for the entire Table.

var myFamily = myRow.family('user');

// get column
myFamily.get('name', function(err, name, apiResponse) {});

// set column(s)
myFamily.set('name', 'peter', function(err, family, apiResponse) {});
// or
myFamily.set({ name: 'peter' }, function (err, family, apiResponse) {});

// delete column(s)
myFamily.delete(['name'], function(err, family, apiResponse) {});

// delete all columns associated with family
myFamily.delete(function(err, apiResponse) {});
@callmehiphop
Copy link
Author

That's cool with me, I just thought I'd throw it out there. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment