toPipelineMapping() function
Home > @cbnsndwch/zero-contracts > toPipelineMapping
toPipelineMapping() function
Converts a simple filter-based mapping to a pipeline-based mapping.
This is useful for migrating existing configurations or when you need pipeline features but want to preserve simple configuration structure.
Signature:
declare function toPipelineMapping<T>(
mapping: SimpleTableMapping<T>
): PipelineTableMapping<T>;Parameters
Parameter
Type
Description
mapping
simple mapping to convert
Returns:
Equivalent pipeline-based mapping
Example
const simple: SimpleTableMapping = {
source: 'accounts',
filter: { bundle: 'ENTERPRISE' },
projection: { _id: 1, name: 1 }
};
const pipeline = toPipelineMapping(simple);
// {
// source: 'accounts',
// pipeline: [{ $match: { bundle: 'ENTERPRISE' } }],
// projection: { _id: 1, name: 1 }
// }How was this page?