Skip to content

Instantly share code, notes, and snippets.

@japel
Last active August 29, 2015 14:05
Show Gist options
  • Save japel/53a927765fef21e472c0 to your computer and use it in GitHub Desktop.
Save japel/53a927765fef21e472c0 to your computer and use it in GitHub Desktop.
// Pets
module.exports = {
attributes:{
type: {
type: 'string'
}
}
};
//PetsController
find: function(req,res,next){
var type = req.param('type');
if(type){
Pets.find({type: type}).exec(function(e,p){
return res.json(p);
});
}
else {
//...
}
}
//route
'get /pets/:type?': {
controller: 'PetsController',
action: 'find'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment