felixge/node-mysql — pull request #164 by thomaslee (2012-01-25 06:42:01+00:00)
Title: Add Client.queryWithEvents().

queryWithEvents() behaves just like query(), but it accepts an EventEmitter instead of a callback. This allows retrieved rows to be passed back to the user one at a time, allowing memory-efficient processing of large result sets.

e.g.

var client = mysql.createClient();

var emitter = new EventEmitter();
emitter.on("row", function(row) { console.log(util.inspect(row)); });
emitter.on("end", function(result) { client.end(); });

client.queryWithEvents("SELECT * FROM table_with_millions_of_rows", emitter);