From c658d7185e1e7ad721d2f830a903914ccb63a22c Mon Sep 17 00:00:00 2001 From: Rea Rustagi <85902999+rustagir@users.noreply.github.com> Date: Mon, 3 Mar 2025 10:46:33 -0500 Subject: [PATCH] DOCSP-43464: operations with builders (#206) * DOCSP-43464: operations with builders * fix desc * shared include fix? * shared include fix? * revert * netlify trigger * small fix * LM PR fixes 1 * LM PR fixes 2 * link fix * reformat comments * JT tech review 2 * fix code example * JT tech review comments (cherry picked from commit e6182b80b469c1953e5b0907eb744d81643e6a3e) --- source/aggregation.txt | 6 + source/builders.txt | 326 ++++++++++++++++++++++++++++++++ source/includes/builders.php | 94 +++++++++ source/index.txt | 7 + source/read/change-streams.txt | 7 +- source/read/specify-a-query.txt | 7 +- 6 files changed, 445 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..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, + '