Skip to content

Commit 2bac862

Browse files
authored
DOCSP-18066: fixed example for DeleteOne (#241)
* DOCSP-18066: fixed example for DeleteOne
1 parent 8eb86f9 commit 2bac862

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ async function run() {
1313
const database = client.db("sample_mflix");
1414
const movies = database.collection("movies");
1515

16-
// Query for a movie that has a title of type string
17-
const query = { title: { $type: "string" } };
16+
// Query for a movie that has title "Annie Hall"
17+
const query = { title: "Annie Hall" };
1818

1919
const result = await movies.deleteOne(query);
2020
if (result.deletedCount === 1) {
21-
console.dir("Successfully deleted one document.");
21+
console.log("Successfully deleted one document.");
2222
} else {
2323
console.log("No documents matched the query. Deleted 0 documents.");
2424
}

source/usage-examples/deleteOne.txt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Example
4141

4242
The following snippet deletes a single document from the ``movies``
4343
collection. It uses a **query document** that configures the query
44-
to match only movies with a title of type ``string``.
44+
to match movies with a ``title`` value of "Annie Hall".
4545

4646
.. include:: /includes/connect-guide-note.rst
4747

@@ -66,9 +66,18 @@ to match only movies with a title of type ``string``.
6666
The JavaScript and TypeScript code snippets above are identical. There are no
6767
TypeScript specific features of the driver relevant to this use case.
6868

69-
If you run the example above, you should see output that resembles the following:
69+
If you run the example, you should see output that resembles the following:
7070

7171
.. code-block:: none
7272
:copyable: false
7373

74-
'Successfully deleted one document.'
74+
Successfully deleted one document.
75+
76+
Because you already deleted the matched document for the query filter,
77+
if you attempt to run the example again you should see output that resembles
78+
the following:
79+
80+
.. code-block:: none
81+
:copyable: false
82+
83+
No documents matched the query. Deleted 0 documents.

0 commit comments

Comments
 (0)