@@ -21,6 +21,10 @@ Definition
21
21
collections </core/capped-collections>`. The remove methods provided
22
22
by the MongoDB drivers use this command internally.
23
23
24
+ .. versionchanged:: 5.0
25
+
26
+ .. _delete-syntax:
27
+
24
28
The :dbcommand:`delete` command has the following syntax:
25
29
26
30
.. code-block:: javascript
@@ -38,7 +42,8 @@ Definition
38
42
...
39
43
],
40
44
ordered: <boolean>,
41
- writeConcern: { <write concern> }
45
+ writeConcern: { <write concern> },
46
+ let: <document> // Added in MongoDB 5.0
42
47
}
43
48
44
49
The command takes the following fields:
@@ -110,6 +115,20 @@ Definition
110
115
.. versionadded:: 4.4
111
116
112
117
118
+ * - :ref:`let <delete-let-syntax>`
119
+
120
+ - document
121
+
122
+ - .. _delete-let-syntax:
123
+
124
+ Optional.
125
+
126
+ .. include:: /includes/let-syntax-generic.rst
127
+
128
+ For an example, see :ref:`delete-let-example`.
129
+
130
+ .. versionadded:: 5.0
131
+
113
132
114
133
.. |operation| replace:: delete
115
134
@@ -414,6 +433,25 @@ To see the index used, run :dbcommand:`explain` on the operation:
414
433
}
415
434
)
416
435
436
+ .. _delete-let-example:
437
+
438
+ .. include:: /includes/let-example-introduction.rst
439
+
440
+ For the syntax, see :ref:`let <delete-let-syntax>`.
441
+
442
+ .. include:: /includes/let-example-delete-flavors.rst
443
+
444
+ .. code-block:: javascript
445
+
446
+ db.runCommand( {
447
+ delete: db.cakeFlavors.getName(),
448
+ deletes: [ {
449
+ q: { $expr: { $eq: [ "$flavor", "$$targetFlavor" ] } },
450
+ limit: 1
451
+ } ],
452
+ let : { targetFlavor: "strawberry" }
453
+ } )
454
+
417
455
.. _delete-command-output:
418
456
419
457
Output
0 commit comments