@cbnsndwch/zero-sources

PipelineMappingBuilder class

Home > @cbnsndwch/zero-contracts > PipelineMappingBuilder

PipelineMappingBuilder class

Builder pattern for constructing pipeline-based table mappings fluently.

Provides a chainable API for building complex pipeline configurations.

Signature:

declare class PipelineMappingBuilder<T>

Example

const mapping = pipelineBuilder<IAccountMember>('accounts')
    .match({ bundle: 'ENTERPRISE' })
    .unwind('$members')
    .match({ 'members.role': { $in: ['admin', 'owner'] } })
    .addFields({
        isOwner: { $eq: ['$members.role', 'owner'] }
    })
    .projection({
        _id: { $concat: ['$_id', '_', '$members.id'] },
        accountId: '$_id',
        userId: '$members.id',
        name: '$members.name',
        role: '$members.role',
        isOwner: 1
    })
    .build();

Constructors

Constructor

Modifiers

Description

(constructor)(source)

Constructs a new instance of the PipelineMappingBuilder class

Methods

Method

Modifiers

Description

addFields(fields)

Adds an $addFields stage to compute new fields

build()

Builds and returns the final pipeline mapping configuration

match(filter)

Adds a $match stage to filter documents

project(projection)

Adds a $project stage to reshape documents at any point in the pipeline

projection(proj)

Sets the projection for the final output

unwind(path)

Adds an $unwind stage to deconstruct an array field

unwind(options)

How was this page?