sidorares/nodejs-mysql-native — Issue #45: Query finished event
Author: mish15
Created: 2011-10-10 05:07:49+00:00
State: open

When executing a db.query function and reading by rows, it's not easy to tell when the query is finished. If you're loading row by row and other executions are waiting on the loading to be complete, then that is an issue. I edited query.js to emit an event when it is complete, now i can load row by row, but still emit an event when the rows are done, see: this.emit("finished"); I think it's a pretty useful event to add. Thanks.

```javascript
data: function( r )
{
if (r.isEOFpacket())
{
var eof = r.readOKpacket();
if (eof.server_status & 8) // SERVER_MORE_RESULTS_EXISTS
{
return 'rs_ok';
}
this.emit('finished');
return 'done';
}
```