Skip to content

Instantly share code, notes, and snippets.

@robwormald
Created February 20, 2014 20:24
Show Gist options
  • Save robwormald/9122439 to your computer and use it in GitHub Desktop.
Save robwormald/9122439 to your computer and use it in GitHub Desktop.
//callbacks
Foo.find({size : 'large'},function(err,data){
if(err){ //something went wrong}
else if(data){ //found some data}
else { //no data found}
})
//alternately, with named callbacks
function queryResponseHandler(err,callback){}
Foo.find({size : 'large'},queryResponseHandler)
//in sails / express req/res context :
someroute : function(req,res){
Foo.find({size: 'large'},function(err,data){
res.json({foos : data})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment