Skip to content

Instantly share code, notes, and snippets.

@durango
Created September 19, 2012 21:31
Show Gist options
  • Select an option

  • Save durango/3752407 to your computer and use it in GitHub Desktop.

Select an option

Save durango/3752407 to your computer and use it in GitHub Desktop.
QueryChainer - adding custom classMethods with complex queries [example]
// This is in classMethods:
a_method: function(id, order_id) {
var query1 = s.Utils.format(['query goes here...']);
var query2 = s.Utils.format(['query goes here....']);
return new s.Utils.CustomEventEmitter(function(emitter) {
db.query(query1, null, {raw:true}).success(function(row1){
db.query(query2, null, {raw:true}).success(function(row2){
emitter.emit('success', {results1: row1, results2: row2});
});
});
}).run();
},
// ....
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment