Created
February 20, 2014 20:24
-
-
Save robwormald/9122439 to your computer and use it in GitHub Desktop.
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
//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