Skip to content

Commit ab47f48

Browse files
committed
change cursor chain const names to be more specific
1 parent e26cd4c commit ab47f48

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

source/crud/query/project.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ field of each document:
6464
:emphasize-lines: 2
6565

6666
// return only* the name field
67-
const projection = { name: 1 };
68-
const cursor = myColl.find().project(projection);
67+
const projectFields = { name: 1 };
68+
const cursor = myColl.find().project(projectFields);
6969
for await (const doc of cursor) {
7070
console.dir(doc);
7171
}
@@ -101,8 +101,8 @@ returned documents.
101101
:emphasize-lines: 2
102102

103103
// return only the name field
104-
const projection = { _id: 0, name: 1 };
105-
const cursor = myColl.find().project(projection);
104+
const projectFields = { _id: 0, name: 1 };
105+
const cursor = myColl.find().project(projectFields);
106106
for await (const doc of cursor) {
107107
console.dir(doc);
108108
}
@@ -130,8 +130,8 @@ order in which they are returned.
130130

131131
.. code-block:: javascript
132132

133-
const projection = { _id: 0, rating: 1, name: 1 };
134-
const cursor = myColl.find().project(projection);
133+
const projectFields = { _id: 0, rating: 1, name: 1 };
134+
const cursor = myColl.find().project(projectFields);
135135
for await (const doc of cursor) {
136136
console.dir(doc);
137137
}

source/crud/query/retrieve.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ see the :ref:`node-fundamentals-query-document` guide.
9696

9797
.. code-block:: javascript
9898

99-
const projection = { _id: 0, field1: 1 };
99+
const projectFields = { _id: 0, field1: 1 };
100100

101-
const findResult = await myColl.findOne().project(projection);
101+
const findResult = await myColl.findOne().project(projectFields);
102102

103103
For more information about projecting document fields, see the
104104
:ref:`node-fundamentals-project` guide.

source/crud/query/specify-documents-to-return.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ lengths:
7474
// define an empty query document
7575
const query = {};
7676
// sort in descending (-1) order by length
77-
const sort = { length: -1 };
78-
const cursor = myColl.find(query).sort(sort);
77+
const sortFields = { length: -1 };
78+
const cursor = myColl.find(query).sort(sortFields);
7979
for await (const doc of cursor) {
8080
console.dir(doc);
8181
}
@@ -106,8 +106,8 @@ add more fields to the sort document:
106106
// define an empty query document
107107
const query = {};
108108
// sort in ascending (1) order by length
109-
const sort = { length: 1, author: 1 };
110-
const cursor = myColl.find(query).sort(sort);
109+
const sortFields = { length: 1, author: 1 };
110+
const cursor = myColl.find(query).sort(sortFields);
111111
for await (const doc of cursor) {
112112
console.dir(doc);
113113
}
@@ -152,9 +152,9 @@ This example performs the following actions:
152152
// define an empty query document
153153
const query = {};
154154
// sort in descending (-1) order by length
155-
const sort = { length: -1 };
156-
const limit = 3;
157-
const cursor = myColl.find(query).sort(sort).limit(limit);
155+
const sortFields = { length: -1 };
156+
const limitNum = 3;
157+
const cursor = myColl.find(query).sort(sortFields).limit(limitNum);
158158
for await (const doc of cursor) {
159159
console.dir(doc);
160160
}
@@ -208,9 +208,9 @@ by performing the following actions:
208208

209209
// define an empty query document
210210
const query = {};
211-
const sort = { length: -1 };
212-
const skip = 4;
213-
const cursor = myColl.find(query).sort(sort).skip(skip);
211+
const sortFields = { length: -1 };
212+
const skipNum = 4;
213+
const cursor = myColl.find(query).sort(sortFields).skip(skipNum);
214214
for await (const doc of cursor) {
215215
console.dir(doc);
216216
}

0 commit comments

Comments
 (0)