Skip to content

Commit 797ffda

Browse files
chore: improve a couple of code examples (#27)
1 parent 3d4f7f4 commit 797ffda

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

source/code-snippets/crud/startrek.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ async function word(movies) {
2626
// end word text example
2727

2828
// print a message if no documents were found
29-
if ((await cursor.count()) == 0) {
29+
if ((await cursor.count()) === 0) {
3030
console.log("No documents found!");
3131
}
3232
await cursor.forEach(console.dir);
@@ -95,7 +95,7 @@ async function relevance(movies) {
9595
// end relevance text example
9696

9797
// print a message if no documents were found
98-
if ((await cursor.count()) == 0) {
98+
if ((await cursor.count()) === 0) {
9999
console.log("No documents found!");
100100
}
101101
await cursor.forEach(console.dir);

source/code-snippets/crud/theaters.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ async function range(theaters) {
5858
// end range geo example
5959

6060
// print a message if no documents were found
61-
if ((await cursor.count()) == 0) {
61+
if ((await cursor.count()) === 0) {
6262
console.log("No documents found!");
6363
}
6464
await cursor.forEach(console.dir);

source/code-snippets/usage-examples/find.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ async function run() {
3232
.project(projection);
3333

3434
// print a message if no documents were found
35-
if (!(await cursor.hasNext())) {
35+
if ((await cursor.count()) === 0) {
3636
console.log("No documents found!");
3737
}
3838

source/code-snippets/usage-examples/insertMany.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ async function run() {
2121
const docs = [docOne, docTwo, docThree];
2222
// specify an additional options object
2323
const options = {};
24-
options.ordered = true; // prevent additional documents from being prevented if one fails
24+
options.ordered = true; // prevent additional documents from being inserted if one fails
2525
const result = await collection.insertMany(docs, options);
2626
console.log(`${result.insertedCount} documents were inserted`);
2727
} finally {

source/code-snippets/usage-examples/insertOne.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ async function run() {
1212

1313
const database = client.db("sample_mflix");
1414
const collection = database.collection("movies");
15-
// create a document object
15+
// create a document to be inserted
1616
const doc = { name: "Red", town: "kanto" };
1717
const result = await collection.insertOne(doc);
1818

0 commit comments

Comments
 (0)