mongodb 3.5.3 → 3.5.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,32 +0,0 @@
1
- 'use strict';
2
-
3
- const Aspect = require('./operation').Aspect;
4
- const defineAspects = require('./operation').defineAspects;
5
- const OperationBase = require('./operation').OperationBase;
6
- const nextObject = require('./common_functions').nextObject;
7
-
8
- class NextOperation extends OperationBase {
9
- constructor(cursor) {
10
- super();
11
-
12
- this.cursor = cursor;
13
- }
14
-
15
- execute(callback) {
16
- const cursor = this.cursor;
17
-
18
- // Return the currentDoc if someone called hasNext first
19
- if (cursor.s.currentDoc) {
20
- const doc = cursor.s.currentDoc;
21
- cursor.s.currentDoc = null;
22
- return callback(null, doc);
23
- }
24
-
25
- // Return the next object
26
- nextObject(cursor, callback);
27
- }
28
- }
29
-
30
- defineAspects(NextOperation, Aspect.SKIP_SESSION);
31
-
32
- module.exports = NextOperation;
@@ -1,66 +0,0 @@
1
- 'use strict';
2
-
3
- const Aspect = require('./operation').Aspect;
4
- const defineAspects = require('./operation').defineAspects;
5
- const handleCallback = require('../utils').handleCallback;
6
- const CursorState = require('../core/cursor').CursorState;
7
- const OperationBase = require('./operation').OperationBase;
8
- const push = Array.prototype.push;
9
-
10
- class ToArrayOperation extends OperationBase {
11
- constructor(cursor) {
12
- super();
13
-
14
- this.cursor = cursor;
15
- }
16
-
17
- execute(callback) {
18
- const cursor = this.cursor;
19
- const items = [];
20
-
21
- // Reset cursor
22
- cursor.rewind();
23
- cursor.s.state = CursorState.INIT;
24
-
25
- // Fetch all the documents
26
- const fetchDocs = () => {
27
- cursor._next((err, doc) => {
28
- if (err) {
29
- return cursor._endSession
30
- ? cursor._endSession(() => handleCallback(callback, err))
31
- : handleCallback(callback, err);
32
- }
33
-
34
- if (doc == null) {
35
- return cursor.close({ skipKillCursors: true }, () =>
36
- handleCallback(callback, null, items)
37
- );
38
- }
39
-
40
- // Add doc to items
41
- items.push(doc);
42
-
43
- // Get all buffered objects
44
- if (cursor.bufferedCount() > 0) {
45
- let docs = cursor.readBufferedDocuments(cursor.bufferedCount());
46
-
47
- // Transform the doc if transform method added
48
- if (cursor.s.transforms && typeof cursor.s.transforms.doc === 'function') {
49
- docs = docs.map(cursor.s.transforms.doc);
50
- }
51
-
52
- push.apply(items, docs);
53
- }
54
-
55
- // Attempt a fetch
56
- fetchDocs();
57
- });
58
- };
59
-
60
- fetchDocs();
61
- }
62
- }
63
-
64
- defineAspects(ToArrayOperation, Aspect.SKIP_SESSION);
65
-
66
- module.exports = ToArrayOperation;