File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -112,6 +112,8 @@ single result or return an iterator containing all results.
112112 If you instead want to look at the built aggregation pipeline, call the
113113``Builder::getPipeline() `` method.
114114
115+ .. _aggregation_builder_hydration :
116+
115117Hydration
116118---------
117119
Original file line number Diff line number Diff line change @@ -983,6 +983,45 @@ the method to be registered.
983983
984984 See :ref: `lifecycle_events ` for more information.
985985
986+ #[QueryResultDocument]
987+ ----------------------
988+
989+ Marks the document as query result document used when hydrating the aggregation query results.
990+ These documents can use all features regular documents can use but they will not be persisted to the database.
991+
992+ .. code-block :: php
993+
994+ <?php
995+
996+ #[QueryResultDocument]
997+ class CompanyTransactions
998+ {
999+ #[ReferenceOne(targetDocument=Company::class, name="_id")]
1000+ private string $company;
1001+
1002+ #[Field]
1003+ private float $totalAmount;
1004+ }
1005+
1006+ Use the ``hydrate() `` method of the Aggregation Builder to specify the class
1007+ to use for hydration.
1008+
1009+ .. code-block :: php
1010+
1011+ <?php
1012+
1013+ $builder = $dm->createAggregationBuilder(Transaction::class);
1014+ $builder
1015+ ->hydrate(CompanyTransactions::class)
1016+ ->group()
1017+ ->field('_id')
1018+ ->expression('$company')
1019+ ->field('totalAmount')
1020+ ->sum('$amount');
1021+
1022+
1023+ See :ref: `aggregation_builder_hydration ` for more information.
1024+
9861025#[ReadPreference]
9871026-----------------
9881027
You can’t perform that action at this time.
0 commit comments