Skip to content

Commit dd6d1c0

Browse files
committed
JT tech review 2
1 parent 1ba5a81 commit dd6d1c0

File tree

1 file changed

+31
-7
lines changed

1 file changed

+31
-7
lines changed

source/builders.txt

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,19 @@ Create a Filter
9090
---------------
9191

9292
You can use factory methods from the ``Query`` builder class to create
93-
filter definitions to use in find, update, and delete operations. To
94-
learn more about creating filters, see the :ref:`php-specify-query` guide.
93+
filter definitions to use in find, update, and delete operations. When
94+
using the ``Query::query()`` factory method to create queries, you can
95+
use named argument syntax and implement type safety. To learn more about
96+
creating filters, see the :ref:`php-specify-query` guide.
9597

9698
The following steps describe how to create a filter definition by using
9799
builders:
98100

99-
1. Instantiate the ``QueryInterface`` by calling the ``Query::query()``
100-
method.
101+
1. Call the ``Query::query()`` method to create a query.
101102

102103
#. Pass the field name to filter on and a factory method from the
103104
``Query`` class. You can pass one or more pairs of field names and
104-
criteria to the ``QueryInterface``.
105+
criteria in the filter to apply multiple clauses.
105106

106107
The following code shows the template to create a filter definition by
107108
using builders:
@@ -114,6 +115,21 @@ using builders:
114115
...
115116
);
116117

118+
To combine query criteria by using logical query operators
119+
(``$and``, ``$or``, ``$not``, ``$nor``), you can use the following
120+
query template:
121+
122+
.. code-block:: php
123+
124+
$filter = Query::<logical operator>(
125+
Query::query(<field name>: Query::<factory method>(<parameters>)),
126+
Query::query(<field name>: Query::<factory method>(<parameters>)),
127+
...
128+
);
129+
130+
To learn more, see :manual:`Logical Query Operators
131+
</reference/operator/query-logical/>` in the {+mdb-server+} manual.
132+
117133
The following sections provide examples that use builders to create
118134
filter definitions for different operations.
119135

@@ -156,10 +172,18 @@ Delete Example
156172

157173
This example performs the following actions:
158174

159-
- Uses the ``Query::regex()`` factory method to match documents in which
160-
the ``feature_type`` field value contains the string ``'nondangerous'``
175+
- Uses the ``Query::or()`` factory method to match documents that
176+
satisfy the either of the following query clauses:
177+
178+
- Clause that uses the ``Query::regex()`` factory method to check if
179+
the ``feature_type`` field value contains the string ``'nondangerous'``
180+
181+
- Clause that uses the ``Query::gt()`` factory method to check if the
182+
``depth`` field value is greater than ``10.0``
183+
161184
- Calls the :phpmethod:`MongoDB\Collection::deleteOne()`
162185
method to delete the first matching document
186+
163187
- Prints the number of deleted documents
164188

165189
.. io-code-block::

0 commit comments

Comments
 (0)