File tree 1 file changed +8
-2
lines changed
1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -729,8 +729,14 @@ Cursor.prototype.each = deprecate(function(callback) {
729
729
* @return {Promise } if no callback supplied
730
730
*/
731
731
Cursor . prototype . forEach = function ( iterator , callback ) {
732
+ // Rewind cursor state
733
+ this . rewind ( ) ;
734
+
735
+ // Set current cursor to INIT
736
+ this . s . state = Cursor . INIT ;
737
+
732
738
if ( typeof callback === 'function' ) {
733
- this . each ( ( err , doc ) => {
739
+ each ( this , ( err , doc ) => {
734
740
if ( err ) {
735
741
callback ( err ) ;
736
742
return false ;
@@ -748,7 +754,7 @@ Cursor.prototype.forEach = function(iterator, callback) {
748
754
} ) ;
749
755
} else {
750
756
return new this . s . promiseLibrary ( ( fulfill , reject ) => {
751
- this . each ( ( err , doc ) => {
757
+ each ( this , ( err , doc ) => {
752
758
if ( err ) {
753
759
reject ( err ) ;
754
760
return false ;
You can’t perform that action at this time.
0 commit comments