Pipeline
Load connected datasets in one operation.
Pipelines extend Core\Collection\Pipeline\Base and map to a Collection. Native aggregations support arbitrary results; cacheable pipelines convert structured results into reusable APPNETOS Documents.
Basic implementation
The following illustrates the relevant class relationship. Replace the example classes with your application's concrete types.
#[\Core\Collection\Pipeline\Annotation\Database(collection: ExampleCollection::class)]
#[\Core\Collection\Pipeline\Annotation\Cacheable]
class ExamplePipeline extends \Core\Collection\Pipeline\Base
{
}
Collection association
A concrete Pipeline declares Core\Collection\Pipeline\Annotation\Database(collection: YourCollection::class). This resolves the Collection used to execute its aggregation.
Native aggregation
Without the Cacheable annotation, aggregate() executes a native MongoDB aggregation and returns the resulting data without APPNETOS Document conversion. This is appropriate for statistics, calculated fields and arbitrary shapes.
Cacheable document pipelines
With Core\Collection\Pipeline\Annotation\Cacheable, the aggregation result must follow the APPNETOS document schema: keys are fully qualified Document class names and values represent null, one Document or multiple Documents. The converter creates typed Documents and makes them available through their associated Collections.
In-memory and Redis reuse
Converted related Documents are registered for request-local reuse. When database caching is active, structured pipeline references and their Documents can also be retained in Redis for subsequent requests.
Design guidance
Use cacheable pipelines when you need a connected dataset with known Document types. Use native aggregations for free-form statistics and projections. Do not treat an arbitrary MongoDB result as a cacheable document pipeline.
Public API Reference
Public methods declared by Core\Collection\Pipeline\Base. Inherited methods are not
repeated
here. Signatures follow the uploaded source implementation.
| Method | Description |
|---|---|
public function __construct() |
Constructor |
public function init(): void |
Initialize |
public function aggregate( array $pipeline, array|null $options = [], ):
array|null |
Aggregate pipeline |
public function getCollectionClassName(): string |
Get collection class name |
public function getCollection(): object |
Get collection |
public function getCacheable(): bool |
Get pipeline is cacheable |