Skip to content

Instantly share code, notes, and snippets.

@jonjenkins
Created May 5, 2011 22:07
Show Gist options
  • Save jonjenkins/958076 to your computer and use it in GitHub Desktop.
Save jonjenkins/958076 to your computer and use it in GitHub Desktop.
Stuffy usage
var s = new Stuffy('mydb');
// the whole enchilada
var s = new Stuffy('mydb');
function done() { console.log('Ding!'); }
function load(iteration) {
switch (iteration) {
case 'yourturn':
s.init('mydb'); // reinitialize the object
s.adapterObj.colsIndex = 'animal,sound'; // sqlite specific, but still cool
s.stash({ jsonUri: 'stuff.json', table: 'animals', jsonFieldMappings: [new FieldMap('sort_order', 'priority', 'INTEGER')] }, 'done();');
break;
default:
s.stash({ jsonUri: 'http://odata.netflix.com/Catalog/Titles', oData: true, getPages: 2, jsonFieldMappings: [new FieldMap('ShortName', 'Title', 'TEXT'), new FieldMap('Synopsis', 'Plot', 'TEXT'), new FieldMap('DateModified', 'LastModified', 'TEXT')], jsonDateFields: 'DateModified', onlyMappedFields: true }, 'load("yourturn");');
break;
}
}
load();
function done() { console.log('Ding!'); }
s.stash('http://odata.netflix.com/Catalog/Genres?$format=json&$callback=callback', 'done();');
s.init('mydb'); // reinitialize the object
function done() { console.log('Twat! (Past tense of Tweet, duh)'); }
s.stash({ jsonUri: 'http://api.twitter.com/1/statuses/user_timeline.json?screen_name=jonjenkins', table: 'twitwit' }, 'done();');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment