Skip to content

Commit b2e92ef

Browse files
authored
DOCSP-17340 cursor updates (#200)
* DOCSP-17340: updates and additions to make access to cursor information easier * DOCSP-17340: updates and additions to make access to cursor information easier * DOCSP-17340: added cursor access note to more pages
1 parent 81e5777 commit b2e92ef

File tree

9 files changed

+35
-14
lines changed

9 files changed

+35
-14
lines changed

source/fundamentals/crud/query-document.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ examples:
4545
{ "_id": 4, "name": "avocados", "qty": 3, "rating": 5 },
4646
]);
4747

48+
.. include:: /includes/access-cursor-note.rst
49+
4850
Literal Value Queries
4951
---------------------
5052

source/fundamentals/crud/read-operations/cursor.txt

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,21 @@ results in a functional style:
7979
:start-after: start foreach cursor example
8080
:end-before: end foreach cursor example
8181

82+
Return an Array of All Documents
83+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
84+
85+
For use cases that require all documents matched by a query to be held
86+
in memory at the same time, use :node-api-4.0:`toArray() </classes/findcursor.html#toarray>`.
87+
Note that large numbers of matched documents can cause performance issues
88+
or failures if the operation exceeds memory constraints. Consider using
89+
:node-api-4.0:`forEach() </classes/findcursor.html#foreach>` to iterate
90+
through results unless you want to return all documents at once.
91+
92+
.. literalinclude:: /code-snippets/crud/cursor.js
93+
:language: javascript
94+
:start-after: start fetchAll cursor example
95+
:end-before: end fetchAll cursor example
96+
8297
Asynchronous Iteration
8398
~~~~~~~~~~~~~~~~~~~~~~
8499

@@ -126,20 +141,6 @@ As Readable Streams, cursors also support the Event API's
126141
:start-after: start event cursor example
127142
:end-before: end event cursor example
128143

129-
Fetch All Documents At Once
130-
~~~~~~~~~~~~~~~~~~~~~~~~~~~
131-
132-
For use cases that require all documents matched by a query to be held
133-
in memory at the same time, use :node-api-4.0:`toArray() </classes/findcursor.html#toarray>`.
134-
Note that large sets of matched documents can cause performance issues or even
135-
failures due to exceeding memory constraints.
136-
137-
.. literalinclude:: /code-snippets/crud/cursor.js
138-
:language: javascript
139-
:start-after: start fetchAll cursor example
140-
:end-before: end fetchAll cursor example
141-
142-
143144
Cursor Utility Methods
144145
----------------------
145146

source/fundamentals/crud/read-operations/limit.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ describe books:
4141
{ "_id": 6, "name": "A Dance With Dragons", "author": "Tolkein", "length": 1104 },
4242
]
4343

44+
.. include:: /includes/access-cursor-note.rst
45+
4446
Limit
4547
-----
4648

source/fundamentals/crud/read-operations/project.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ varieties of fruit:
4343
{ "_id": 4, "name": "avocados", "qty": 3, "rating": 5 },
4444
]
4545

46+
.. include:: /includes/access-cursor-note.rst
47+
4648
Single Field
4749
------------
4850

source/fundamentals/crud/read-operations/retrieve.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ If you want to monitor the database for incoming data that matches a set of
3535
criteria, you can use the watch operation to be notified in real-time when
3636
matching data is inserted.
3737

38+
.. include:: /includes/access-cursor-note.rst
39+
3840
Find
3941
----
4042

source/fundamentals/crud/read-operations/skip.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ fruit:
4242
{ "_id": 4, "name": "avocados", "qty": 3, "rating": 5 },
4343
]
4444

45+
.. include:: /includes/access-cursor-note.rst
46+
4547
Example
4648
-------
4749

source/fundamentals/crud/read-operations/sort.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ insert this data into a collection, run the following operation:
4040
{ "_id": 6, "name": "A Dance with Dragons", "author": "Martin", "length": 1104 },
4141
]);
4242

43+
.. include:: /includes/access-cursor-note.rst
44+
4345
Example
4446
-------
4547

source/fundamentals/crud/read-operations/text.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ Querying with the negated term yields the following documents:
153153
{ title: 'Star Trek III: The Search for Spock' }
154154
{ title: 'Star Trek II: The Wrath of Khan' }
155155

156+
.. include:: /includes/access-cursor-note.rst
157+
156158
Sort by Relevance
157159
~~~~~~~~~~~~~~~~~
158160

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.. note::
2+
3+
Your query operation may return a reference to a
4+
cursor that contains matching documents. To learn how to
5+
examine data stored in the cursor, see the
6+
:doc:`Cursor Fundamentals page </fundamentals/crud/read-operations/cursor>`.

0 commit comments

Comments
 (0)