@@ -7,6 +7,11 @@ module.exports = Object.create(null);
7
7
Object . defineProperty ( module . exports , '__esModule' , { value : true } ) ;
8
8
9
9
module . exports . makeLegacyFindCursor = function ( baseClass ) {
10
+ function toLegacyHelper ( cursor ) {
11
+ Object . setPrototypeOf ( cursor , LegacyFindCursor . prototype ) ;
12
+ return cursor ;
13
+ }
14
+
10
15
class LegacyFindCursor extends baseClass {
11
16
/** @deprecated Use `collection.estimatedDocumentCount` or `collection.countDocuments` instead */
12
17
count ( options , callback ) {
@@ -56,19 +61,28 @@ module.exports.makeLegacyFindCursor = function (baseClass) {
56
61
tryNext ( callback ) {
57
62
return maybeCallback ( super . tryNext ( ) , callback ) ;
58
63
}
64
+ clone ( ) {
65
+ const cursor = super . clone ( ) ;
66
+ return toLegacyHelper ( cursor ) ;
67
+ }
59
68
}
60
69
61
70
Object . defineProperty ( baseClass . prototype , toLegacy , {
62
71
enumerable : false ,
63
72
value : function ( ) {
64
- return Object . setPrototypeOf ( this , LegacyFindCursor . prototype ) ;
73
+ return toLegacyHelper ( this ) ;
65
74
}
66
75
} ) ;
67
76
68
77
return LegacyFindCursor ;
69
78
} ;
70
79
71
80
module . exports . makeLegacyListCollectionsCursor = function ( baseClass ) {
81
+ function toLegacyHelper ( cursor ) {
82
+ Object . setPrototypeOf ( cursor , LegacyListCollectionsCursor . prototype ) ;
83
+ return cursor ;
84
+ }
85
+
72
86
class LegacyListCollectionsCursor extends baseClass {
73
87
close ( options , callback ) {
74
88
callback =
@@ -95,19 +109,28 @@ module.exports.makeLegacyListCollectionsCursor = function (baseClass) {
95
109
tryNext ( callback ) {
96
110
return maybeCallback ( super . tryNext ( ) , callback ) ;
97
111
}
112
+ clone ( ) {
113
+ const cursor = super . clone ( ) ;
114
+ return toLegacyHelper ( cursor ) ;
115
+ }
98
116
}
99
117
100
118
Object . defineProperty ( baseClass . prototype , toLegacy , {
101
119
enumerable : false ,
102
120
value : function ( ) {
103
- return Object . setPrototypeOf ( this , LegacyListCollectionsCursor . prototype ) ;
121
+ return toLegacyHelper ( this ) ;
104
122
}
105
123
} ) ;
106
124
107
125
return LegacyListCollectionsCursor ;
108
126
} ;
109
127
110
128
module . exports . makeLegacyListIndexesCursor = function ( baseClass ) {
129
+ function toLegacyHelper ( cursor ) {
130
+ Object . setPrototypeOf ( cursor , LegacyListIndexesCursor . prototype ) ;
131
+ return cursor ;
132
+ }
133
+
111
134
class LegacyListIndexesCursor extends baseClass {
112
135
close ( options , callback ) {
113
136
callback =
@@ -134,19 +157,28 @@ module.exports.makeLegacyListIndexesCursor = function (baseClass) {
134
157
tryNext ( callback ) {
135
158
return maybeCallback ( super . tryNext ( ) , callback ) ;
136
159
}
160
+ clone ( ) {
161
+ const cursor = super . clone ( ) ;
162
+ return toLegacyHelper ( cursor ) ;
163
+ }
137
164
}
138
165
139
166
Object . defineProperty ( baseClass . prototype , toLegacy , {
140
167
enumerable : false ,
141
168
value : function ( ) {
142
- return Object . setPrototypeOf ( this , LegacyListIndexesCursor . prototype ) ;
169
+ return toLegacyHelper ( this ) ;
143
170
}
144
171
} ) ;
145
172
146
173
return LegacyListIndexesCursor ;
147
174
} ;
148
175
149
176
module . exports . makeLegacyAggregationCursor = function ( baseClass ) {
177
+ function toLegacyHelper ( cursor ) {
178
+ Object . setPrototypeOf ( cursor , LegacyAggregationCursor . prototype ) ;
179
+ return cursor ;
180
+ }
181
+
150
182
class LegacyAggregationCursor extends baseClass {
151
183
explain ( verbosity , callback ) {
152
184
callback =
@@ -184,12 +216,16 @@ module.exports.makeLegacyAggregationCursor = function (baseClass) {
184
216
tryNext ( callback ) {
185
217
return maybeCallback ( super . tryNext ( ) , callback ) ;
186
218
}
219
+ clone ( ) {
220
+ const cursor = super . clone ( ) ;
221
+ return toLegacyHelper ( cursor ) ;
222
+ }
187
223
}
188
224
189
225
Object . defineProperty ( baseClass . prototype , toLegacy , {
190
226
enumerable : false ,
191
227
value : function ( ) {
192
- return Object . setPrototypeOf ( this , LegacyAggregationCursor . prototype ) ;
228
+ return toLegacyHelper ( this ) ;
193
229
}
194
230
} ) ;
195
231
0 commit comments