@@ -31,6 +31,9 @@ This guide includes the following sections:
31
31
- :ref:`Delete Operations <rust-delete-operations>` describes how to use the
32
32
driver to execute delete operations
33
33
34
+ - :ref:`Delete Examples <rust-delete-operations>` provides code examples
35
+ for the delete operations
36
+
34
37
- :ref:`Additional Information <rust-crud-del-addtl-info>`
35
38
provides links to resources and API documentation for types
36
39
and methods mentioned in this guide
@@ -152,8 +155,40 @@ which describes the number of documents deleted. If no documents match
152
155
the query filter you specified, the delete operation does
153
156
not remove any documents, and the value of ``deleted_count`` is ``0``.
154
157
155
- delete_many() Example
156
- ~~~~~~~~~~~~~~~~~~~~~
158
+ Delete Examples
159
+ ---------------
160
+
161
+ This section provides code examples for the following delete operations:
162
+
163
+ - :ref:`delete_one() <rust-delete-one-ex>`
164
+ - :ref:`delete_many() <rust-delete-many-ex>`
165
+
166
+ .. _rust-delete-one-ex:
167
+
168
+ Delete One Example
169
+ ~~~~~~~~~~~~~~~~~~
170
+
171
+ The following example uses the ``delete_one()`` method to delete a document
172
+ that has an ``item`` value of ``"placemat"``:
173
+
174
+ .. io-code-block::
175
+
176
+ .. input:: /includes/fundamentals/code-snippets/crud/delete.rs
177
+ :start-after: begin-delete-one
178
+ :end-before: end-delete-one
179
+ :language: rust
180
+ :dedent:
181
+
182
+ .. output::
183
+ :language: console
184
+ :visible: false
185
+
186
+ Deleted documents: 1
187
+
188
+ .. _rust-delete-many-ex:
189
+
190
+ Delete Many Example
191
+ ~~~~~~~~~~~~~~~~~~~
157
192
158
193
This example performs the following actions:
159
194
@@ -163,12 +198,11 @@ This example performs the following actions:
163
198
- Chains the ``hint()`` method to ``delete_many()`` to use the ``_id_`` index as the hint
164
199
for the delete operation
165
200
166
-
167
201
.. io-code-block::
168
202
169
203
.. input:: /includes/fundamentals/code-snippets/crud/delete.rs
170
- :start-after: begin-delete
171
- :end-before: end-delete
204
+ :start-after: begin-delete-many
205
+ :end-before: end-delete-many
172
206
:language: rust
173
207
:dedent:
174
208
0 commit comments