Skip to content

Commit

Permalink
test: clarify findAsCursor return type
Browse files Browse the repository at this point in the history
  • Loading branch information
Eli Skeggs committed Mar 30, 2020
1 parent b172775 commit 3a65f38
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -114,6 +114,12 @@ db.collection('foo').find(...);
// find everything in mycollection returned as array
const documents = await db.mycollection.find();

// find everything in mycollection returned as a Cursor (no intermediate Promise)
const documentsCursor = db.mycollection.findAsCursor();

// take the first document from the cursor
const document = await documentsCursor.next();

// find everything in mycollection, but sort by name
const sortedDocuments = await db.mycollection.findAsCursor().sort({name: 1}).toArray();

Expand Down

0 comments on commit 3a65f38

Please sign in to comment.