Skip to content

Commit 0fb654e

Browse files
committed
Fixed issue where Cursor.prototype.next method did not behave in same manner as nextObject
1 parent a24a67c commit 0fb654e

File tree

4 files changed

+12
-16
lines changed

4 files changed

+12
-16
lines changed

lib/aggregation_cursor.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,6 @@ var AggregationCursor = function(bson, ns, cmd, options, topology, topologyOptio
128128
// Inherit from Readable
129129
inherits(AggregationCursor, Readable);
130130

131-
// Map core cursor _next method so we can apply mapping
132-
CoreCursor.prototype._next = CoreCursor.prototype.next;
133-
134131
// Extend the Cursor
135132
for(var name in CoreCursor.prototype) {
136133
AggregationCursor.prototype[name] = CoreCursor.prototype[name];

lib/command_cursor.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,6 @@ inherits(CommandCursor, Readable);
132132
var methodsToInherit = ['_next', 'next', 'each', 'forEach', 'toArray'
133133
, 'rewind', 'bufferedCount', 'readBufferedDocuments', 'close', 'isClosed'];
134134

135-
// // Map core cursor _next method so we can apply mapping
136-
// CoreCursor.prototype._next = CoreCursor.prototype.next;
137-
138135
// Only inherit the types we need
139136
for(var i = 0; i < methodsToInherit.length; i++) {
140137
CommandCursor.prototype[methodsToInherit[i]] = CoreCursor.prototype[methodsToInherit[i]];

lib/cursor.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,6 @@ for(var name in CoreCursor.prototype) {
155155
Cursor.prototype[name] = CoreCursor.prototype[name];
156156
}
157157

158-
Cursor.prototype.mister = function() {}
159-
160158
/**
161159
* Set the cursor query
162160
* @method
@@ -342,14 +340,6 @@ Cursor.prototype.skip = function(value) {
342340
* @param {(object|null)} result The result object if the command was executed successfully.
343341
*/
344342

345-
/**
346-
* Get the next available document from the cursor, returns null if no more documents are available.
347-
* @function external:CoreCursor#next
348-
* @param {Cursor~resultCallback} callback The result callback.
349-
* @throws {MongoError}
350-
* @return {null}
351-
*/
352-
353343
/**
354344
* Set the new batchSize of the cursor
355345
* @function Cursor.prototype.setBatchSize
@@ -450,6 +440,16 @@ var loop = function(self, callback) {
450440
return loop;
451441
}
452442

443+
/**
444+
* Get the next available document from the cursor, returns null if no more documents are available.
445+
* @method
446+
* @param {Cursor~resultCallback} callback The result callback.
447+
* @throws {MongoError}
448+
* @deprecated
449+
* @return {Promise} returns Promise if no callback passed
450+
*/
451+
Cursor.prototype.next = Cursor.prototype.nextObject;
452+
453453
/**
454454
* Iterates over all the documents for this cursor. As with **{cursor.toArray}**,
455455
* not all of the elements will be iterated if this cursor had been previouly accessed.

test/functional/cursor_tests.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ exports.cursorShouldBeAbleToResetOnToArrayRunningQueryAgain = {
1919

2020
collection.insert({'a':1}, configuration.writeConcernMax(), function(err, ids) {
2121
var cursor = collection.find({});
22+
console.log("--------------------------------- TOARRAY 0")
2223
cursor.toArray(function(err, items) {
24+
console.log("--------------------------------- TOARRAY 1")
2325
// Should fail if called again (cursor should be closed)
2426
cursor.toArray(function(err, items) {
2527
test.equal(null, err);

0 commit comments

Comments
 (0)