diff --git a/source/aggregation.txt b/source/aggregation.txt index 2ec29c8f..7fb5c52f 100644 --- a/source/aggregation.txt +++ b/source/aggregation.txt @@ -228,6 +228,12 @@ The examples in this section are adapted from the {+mdb-server+} manual. Each example provides a link to the sample data that you can insert into your database to test the aggregation operation. +.. tip:: Operations with Builders + + You can use builders to support non-aggregation operations such as + find and update operations. To learn more, see the :ref:`php-builders` + guide. + Filter and Group Example ~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/source/builders.txt b/source/builders.txt new file mode 100644 index 00000000..5f6f77ae --- /dev/null +++ b/source/builders.txt @@ -0,0 +1,326 @@ +.. _php-builders: + +======================== +Operations with Builders +======================== + +.. contents:: On this page + :local: + :backlinks: none + :depth: 2 + :class: singlecol + +.. facet:: + :name: genre + :values: reference + +.. meta:: + :keywords: aggregation, query, code example, type-safe + +Overview +-------- + +In this guide, you can learn about the **builder classes** +that the {+library-short+} provides to create types used in your +operations. You can use the builder classes and factory methods from the +Aggregation Builder feature to create filters for other operations such +as find, update, and delete operations. To learn more about the Aggregation +Builder, see the :ref:`php-aggregation-builder-api` section of the +Aggregation guide. + +Using builders to create queries helps you identify errors at compile +time and avoid them at runtime. This guide provides information on +builder classes that you can use to perform the following tasks: + +- :ref:`php-builders-filter` +- :ref:`php-builders-update` +- :ref:`php-builders-changestream` + +.. note:: Setting Operation Options + + You cannot specify options by using factory methods for the equivalent + aggregation stages. For example, you cannot use the ``Stage::limit()`` method + to set a returned documents limit on your find operation. You must specify + options by using the string-based syntax, as shown in the following code: + + .. code-block:: php + + $options = [ + 'limit' => 5, + '