Skip to content

Instantly share code, notes, and snippets.

@callmehiphop
Last active August 29, 2015 14:25
Show Gist options
  • Save callmehiphop/d6b780ad9a51e0a91625 to your computer and use it in GitHub Desktop.
Save callmehiphop/d6b780ad9a51e0a91625 to your computer and use it in GitHub Desktop.
// collection style
var qualifierCollection = [{
family: 'user',
qualifier: 'tagged',
$: 'bfranklin'
}, {
family: 'user',
qualifier: 'tagger',
$: 'alincoln'
}];
// simple hash using bigtable syntax
var qualifierSimpleHash = {
'user:tagged': 'bfranklin',
'user:tagger': 'alincoln'
};
// nested objects
var qualifierNestedObjs = {
user: {
tagged: 'bfranklin',
tagger: 'alincoln'
}
};
var gcloud = require('gcloud')({ ... });
var bigtable = gcloud.bigtable();
var prezzy = bigtable.table('prezzy');
var lincoln = prezzy.row('lincoln');
// this is where that data would go
lincoln.put(qualifiers, function (err, apiResponse) {
if (err) console.log('sad times');
});
@stephenplusplus
Copy link

Using this prezzy example:

Make jadams follow wmckinley:

var prezzy = bigtable.table('prezzy');
var jadams = prezzy.row('jadams');

jadams.family('follows').set('wmckinley', 1, function(err, apiResponse) {});

Make tjefferson, wmckinley, and gwashington follow jadams:

var prezzy = bigtable.table('prezzy');

var rows = prezzy.rows(['tjefferson', 'wmckinley', 'gwashington']);
// alternative:
// var tjefferson = prezzy.row('tjefferson');
// var wmckinley = prezzy.row('wmckinley');
// var gwashington = prezzy.row('gwashington');
// var rows = prezzy.rows([tjeferrson, wmckinley, gwashington]);

rows.family('follows').set('jadams', 1, function(err, apiResponse) {});

Is that awful?

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