Calling functions outside paths

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. :)

To be sure what you are trying to accomplish:

Is your intent to use the results of the find call in your response from the server? You could wrap the find in a function that takes in the response as a parameter, and then define the callback to the find with the response accessed inside it.

For example (untested code, but this is the idea):

// function called when a request is received
function getBirds(searchTerm, res) {
    birds = db.birds.find(searchTerm, function(err, docs) {
        // code in here will have access to res because it is in a closure
    });
}

You typically do this by wrapping the callback function call in an anonymous function:

db.birds.find(searchTerm, function (err, birds) {
    callback (err, birds, res);
});