Skip to content

Function: compilePipeline()

compilePipeline(filters, schema, options?): Document[]

Defined in: src/query/compiler.ts:37

Compiles a Django-style field__lookup filter object into a MongoDB aggregation pipeline. Pure and DB-free — this is the heart of DORM and the most heavily unit-tested part.

Advanced / low-level. Most callers should use the Model.objects query API; this is exported for tooling, introspection, and testing. Its signature is part of the public API and follows the project's stability policy.

A path is split on __. A trailing operator (e.g. gte) is peeled off. Remaining segments are walked against the schema: a ref field (that is not the final segment) emits a $lookup + $unwind and descends into the referenced schema; every other segment accumulates into a dotted path that becomes a single $match.

Parameters

filters

Record<string, unknown>

schema

SchemaDef

options?

CompileOptions = {}

Returns

Document[]

Released under the MIT License.