> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# Resource: Items

# Type: PipelineBuilder

# Action: withStages

# Link: https://dev.wix.com/docs/sdk/data-items-sdk/data/items/pipeline-builder/with-stages.md

## Description: Adds [pipeline stages](https://dev.wix.com/docs/sdk/backend-modules/data/items/wix-data-aggregate-pipeline-stages/introduction.md) to the aggregation pipeline.

Stages are processed sequentially in the order they are provided, with each stage's output becoming the input for the next stage.

## Schema:

```json
 Method: withStages(stages)
 Description: Adds [pipeline stages](https://dev.wix.com/docs/sdk/backend-modules/data/items/wix-data-aggregate-pipeline-stages/introduction.md) to the aggregation pipeline.  Stages are processed sequentially in the order they are provided, with each stage's output becoming the input for the next stage.
 Method parameters:
   param name:  stages | type: Array<PipelineStage> | description:  Array of [pipeline stages](https://dev.wix.com/docs/sdk/backend-modules/data/items/wix-data-aggregate-pipeline-stages/introduction.md). 
 Return type: REFERENCE<PipelineBuilder>
     Method: build()
     Description: Builds the aggregation pipeline.  Run this method after configuring stages and pagination to build the aggregation pipeline. Specify the pipeline as the `pipeline` parameter when calling the [`aggregatePipeline()`](https://dev.wix.com/docs/sdk/backend-modules/data/items/aggregate-pipeline.md) method.
     Return type: REFERENCE<AggregationPipeline>
         - name: cursorPaging  | type: CursorPaging | description:  Cursor token referring to a page of results.  Not used in the first request. Subsequent requests use the cursor token and not `filter` or `sort`. 
         - name: paging  | type: Paging | description:  Paging options to limit and skip the number of results. Call [`withPaging()`](https://dev.wix.com/docs/sdk/backend-modules/data/items/pipeline-builder/with-stages.md) to configure paging.  Learn more about [sorting and paging](https://dev.wix.com/docs/rest/articles/get-started/sorting-and-paging.md). 
         - name: stages  | type: Array<Stage> | description:  Sequence of aggregation operations to apply to the data. Stages are processed in order, with each stage operating on the output of the previous stage.  Call [`withStages()`](https://dev.wix.com/docs/sdk/backend-modules/data/items/pipeline-builder/with-stages.md) to add and configure aggregation stages. 
     Method: withPaging(paging)
     Description: Configures pagination for the aggregation pipeline results.  You can specify either [offset](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/api-query-language.md#offset-paging) or [cursor pagination](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/api-query-language.md#cursor-paging).
     Method parameters:
       param name:  paging | type: undefined | description:  Pagination configuration. 
     Return type: REFERENCE<PipelineBuilder>
     Method: withStages(stages)
     Description: Adds [pipeline stages](https://dev.wix.com/docs/sdk/backend-modules/data/items/wix-data-aggregate-pipeline-stages/introduction.md) to the aggregation pipeline.  Stages are processed sequentially in the order they are provided, with each stage's output becoming the input for the next stage.
     Method parameters:
       param name:  stages | type: Array<PipelineStage> | description:  Array of [pipeline stages](https://dev.wix.com/docs/sdk/backend-modules/data/items/wix-data-aggregate-pipeline-stages/introduction.md). 
     Return type: REFERENCE<PipelineBuilder>

```