Skip to content

Commit

Permalink
Change cursor appply method to support mongo driver 1.4.0. Refs #126 #…
Browse files Browse the repository at this point in the history
  • Loading branch information
sorribas committed Apr 9, 2014
1 parent bc4f031 commit a802934
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
25 changes: 12 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ var EventEmitter = require('events').EventEmitter;
var Readable = require('stream').Readable || require('readable-stream');

var DRIVER_COLLECTION_PROTO = mongodb.Collection.prototype;
var DRIVER_CURSOR_PROTO = mongodb.Cursor.prototype;
var DRIVER_DB_PROTO = mongodb.Db.prototype;

var noop = function() {};
Expand Down Expand Up @@ -48,47 +47,47 @@ var Cursor = function(oncursor) {
util.inherits(Cursor, Readable);

Cursor.prototype.toArray = function() {
this._apply(DRIVER_CURSOR_PROTO.toArray, arguments);
this._apply('toArray', arguments);
};

Cursor.prototype.next = function() {
this._apply(DRIVER_CURSOR_PROTO.nextObject, arguments);
this._apply('nextObject', arguments);
};

Cursor.prototype.forEach = function() {
this._apply(DRIVER_CURSOR_PROTO.each, arguments);
this._apply('each', arguments);
};

Cursor.prototype.count = function() {
this._apply(DRIVER_CURSOR_PROTO.count, arguments);
this._apply('count', arguments);
};

Cursor.prototype.explain = function() {
this._apply(DRIVER_CURSOR_PROTO.explain, arguments);
this._apply('explain', arguments);
};

Cursor.prototype.limit = function() {
return this._config(DRIVER_CURSOR_PROTO.limit, arguments);
return this._config('limit', arguments);
};

Cursor.prototype.skip = function() {
return this._config(DRIVER_CURSOR_PROTO.skip, arguments);
return this._config('skip', arguments);
};

Cursor.prototype.batchSize = function() {
return this._config(DRIVER_CURSOR_PROTO.batchSize, arguments);
return this._config('batchSize', arguments);
};

Cursor.prototype.sort = function() {
return this._config(DRIVER_CURSOR_PROTO.sort, arguments);
return this._config('sort', arguments);
};

Cursor.prototype.rewind = function() {
return this._config(DRIVER_CURSOR_PROTO.rewind, arguments);
return this._config('rewind', arguments);
};

Cursor.prototype.destroy = function() {
this._apply(DRIVER_CURSOR_PROTO.close, arguments);
this._apply('close', arguments);
this.push(null);
};

Expand All @@ -106,7 +105,7 @@ Cursor.prototype.size = function(callback) {
Cursor.prototype._apply = function(fn, args) {
this._get(function(err, cursor) {
if (err) return getCallback(args)(err);
fn.apply(cursor, args);
cursor[fn].apply(cursor, args);
});

return this;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"dependencies": {
"thunky": "~0.1.0",
"readable-stream": "~1.1.9",
"mongodb": "1.3.19"
"mongodb": "1.4.0"
},
"scripts": {
"test": "node ./tests"
Expand Down

0 comments on commit a802934

Please sign in to comment.