router.post('/getRides', function(req, res, next) { var io = req.app.get('socketio'); io.to(//socket.id//).emit("message", data); db.rides.find(function(err, docs) { res.json(docs); }); };