Skip to content

Commit

Permalink
Merge remote-tracking branch 'sethtml/streamRecords'
Browse files Browse the repository at this point in the history
  • Loading branch information
christkv committed Aug 27, 2011
2 parents 7c5ce93 + 9676e9c commit 0056e66
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/mongodb/cursor.js
Expand Up @@ -596,7 +596,11 @@ Cursor.prototype.streamRecords = function(options) {

function execute(command) {
self.db.executeCommand(command, {read:true}, function(err,result) {
if(err != null) return callback(err, null);
if(err) {
stream.emit('error', err);
self.close(function(){});
return;
}

if (!self.queryRun && result) {
self.queryRun = true;
Expand All @@ -617,9 +621,11 @@ Cursor.prototype.streamRecords = function(options) {
} catch(err) {
if (err != "done") { throw err; }
else {
stream.emit('end', recordLimitValue);
self.close(function(){
stream.emit('end', recordLimitValue);
});
self.close(function(){});
return(null);
return;
}
}
// rinse & repeat
Expand Down

0 comments on commit 0056e66

Please sign in to comment.