When I use expressjs, but I don’t know how to use it with streamlinejs.
Look at the express code:
var app = express.createServer();
app.get('/', function(req,res) {
User.find({name:'Jack'}, function(err, users) {
res.send(users);
});
});
How to use streamlinejs in the code?
That’s a point I’m covering quickly in the FAQ (https://github.com/Sage/streamlinejs/blob/master/FAQ.md#the-underscore-trick-is-designed-for-callbacks-but-not-events-how-do-i-deal-with-events).
The easiest solution is to add the underscore as extra parameter to the
getcallback:The only problem would be if
connectadds a fourth parameter to its callback some day. The following is a bit safer (but probably overkill because I don’t see whyconnectwould change its callback API):