File tree Expand file tree Collapse file tree 4 files changed +20
-4
lines changed
source/code-snippets/indexes Expand file tree Collapse file tree 4 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -31,10 +31,14 @@ async function run() {
3131 const projection = { _id : 0 , type : 1 , genre : 1 } ;
3232
3333 // Execute the query using the defined criteria and projection
34- const cursor = await movies
34+ const cursor = movies
3535 . find ( query )
3636 . sort ( sort )
3737 . project ( projection ) ;
38+
39+ for await ( const doc of cursor ) {
40+ console . log ( doc ) ;
41+ }
3842 // end-query
3943
4044 } finally {
Original file line number Diff line number Diff line change @@ -26,9 +26,13 @@ async function run() {
2626 const projection = { _id : 0 , cast : 1 , title : 1 } ;
2727
2828 // Perform a find operation with the preceding filter and projection
29- const cursor = await movies
29+ const cursor = movies
3030 . find ( query )
3131 . project ( projection ) ;
32+
33+ for await ( const doc of cursor ) {
34+ console . log ( doc ) ;
35+ }
3236 // end-query
3337
3438 } finally {
Original file line number Diff line number Diff line change @@ -25,10 +25,14 @@ async function run() {
2525 const sort = { title : 1 } ;
2626 const projection = { _id : 0 , title : 1 } ;
2727 // Execute the query using the defined parameters
28- const cursor = await movies
28+ const cursor = movies
2929 . find ( query )
3030 . sort ( sort )
3131 . project ( projection ) ;
32+
33+ for await ( const doc of cursor ) {
34+ console . log ( doc ) ;
35+ }
3236 // end-query
3337 } finally {
3438 await client . close ( ) ;
Original file line number Diff line number Diff line change @@ -33,7 +33,11 @@ async function run() {
3333 const projection = { _id : 0 , title : 1 } ;
3434
3535 // Execute the find operation
36- const cursor = await myColl . find ( query ) . project ( projection ) ;
36+ const cursor = myColl . find ( query ) . project ( projection ) ;
37+
38+ for await ( const doc of cursor ) {
39+ console . log ( doc ) ;
40+ }
3741 // end-query
3842 } finally {
3943 await client . close ( ) ;
You can’t perform that action at this time.
0 commit comments