Skip to content

Commit 1f5a63d

Browse files
rustagirmongoKart
authored andcommitted
DOCSP-32718: deleteone UE code comments (mongodb#756)
* DOCSP-32718: deleteone UE code comments * CC comments * CC comments
1 parent 1019558 commit 1f5a63d

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed
Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
// Delete a document
2+
13
import { MongoClient } from "mongodb";
24

3-
// Replace the uri string with your MongoDB deployment's connection string.
5+
// Replace the uri string with your MongoDB deployment's connection string
46
const uri = "<connection string uri>";
57

68
const client = new MongoClient(uri);
@@ -10,17 +12,22 @@ async function run() {
1012
const database = client.db("sample_mflix");
1113
const movies = database.collection("movies");
1214

13-
// Query for a movie that has title "Annie Hall"
15+
/* Delete the first document in the "movies" collection that matches
16+
the specified query document */
1417
const query = { title: "Annie Hall" };
15-
1618
const result = await movies.deleteOne(query);
19+
20+
/* Print a message that indicates whether the operation deleted a
21+
document */
1722
if (result.deletedCount === 1) {
1823
console.log("Successfully deleted one document.");
1924
} else {
2025
console.log("No documents matched the query. Deleted 0 documents.");
2126
}
2227
} finally {
28+
// Close the connection after the operation completes
2329
await client.close();
2430
}
2531
}
32+
// Run the program and print any thrown exceptions
2633
run().catch(console.dir);

0 commit comments

Comments
 (0)