Created
May 5, 2011 22:07
-
-
Save jonjenkins/958076 to your computer and use it in GitHub Desktop.
Stuffy usage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var s = new Stuffy('mydb'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function done() { console.log('Ding!'); } | |
s.stash('http://odata.netflix.com/Catalog/Genres?$format=json&$callback=callback', 'done();'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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