Calling functions outside paths
- by user1775718
In mongojs, when you do:
var birds = db.birds.find(searchTerm, callback);
...how do you pass arguments to the callback? I've tried bind, as in:
birds = db.birds.find(searchTerm, app.get('getBirds').bind(res));
...but to no avail. Just fyi I'm trying to pass the response object of the GET route so that the callback can render using res.send(results).
The other option is to set app.set('res': res); and call app.get('res') from the callback - I'm not sure this is a good idea. It works, but it doesn't obey the events loop model too well - I think the request back to the app may be costly? Any help would be gratefully accepted. :)