Streaming Results and res.render nodejs

I am using express and mysql-native with nodejs. With the mysql-native I stream results from the db row by row like this (in coffee):

exports.getUser = (username,callback) ->
 query = mysql.query "select * from users where username = #{username}"
 query.on "row", (row)->
  callback row

(obviously I would use prepared statements this is an example)

This sort of method won't work with res.render because you cannot be calling the res.render multiple times every time you get a new row

database.getUser "username", (result)->
  res.render "people", "data" : result 

Is there some other method for sending streamed data or would I have to stream results to the view with sockets?

you can use your preferred templating engine directly

var row = _.template('<tr><td> <%= id > </td> </tr>');
...
database.getUser "username", (result)->
  res.write( row(result) );

You may want to use Express partials.

I figured it out last night in a moment of inspiration since I am streaming the data I can listen for when the stream ends and run my callback. That way I can push the data to an array then use in on a callback like so:

 query = mysql.query "select * from users where id = 2"
 data = []
 query.on "row", (row)->
   data.push row
 query.on "end", ()->
   callback data