From c74e04ab3cc53ea792affc6448132d2109603c73 Mon Sep 17 00:00:00 2001 From: rustagir Date: Tue, 18 Feb 2025 09:56:58 -0500 Subject: [PATCH 01/14] DOCSP-43464: operations with builders --- source/aggregation.txt | 6 + source/builders.txt | 304 ++++++++++++++++++++++++++++++++ source/includes/builders.php | 76 ++++++++ source/index.txt | 7 + source/read/change-streams.txt | 7 +- source/read/specify-a-query.txt | 7 +- 6 files changed, 405 insertions(+), 2 deletions(-) create mode 100644 source/builders.txt create mode 100644 source/includes/builders.php 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..477e87e4 --- /dev/null +++ b/source/builders.txt @@ -0,0 +1,304 @@ +.. _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 +:ref:`php-aggregation-builder-api` feature to create filters for other +operations such as find, update, and delete operations. + +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 for the following tasks: + +- :ref:`Creating a filter definition ` +- :ref:`Defining an update operation ` +- :ref:`Filtering a change stream ` + +.. note:: 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, + '