0.4.0 • Published 9 months ago

mongoose-aggregation-pipeline-builder v0.4.0

Weekly downloads
-
License
ISC
Repository
github
Last release
9 months ago

PipelineStageBuilder

A fluent builder for MongoDB aggregation pipeline stages

new PipelineStageBuilder().$match({ _id: "_id" }).$project({ _id: 1 });
const aggregation = new PipelineStageBuilder()
  .$match({ _id: "_id" })
  .$project({ _id: 1 })
  .build();

const result = await model.aggregate(aggregation);

Migration

Generate string template from array of aggregation pipeline stages. This makes it easier to convert an array of stages into a string template

PipelineStageBuilder.fromArray([
  {
    $match: {
      _id: "_id",
    },
  },
  {
    $project: {
      _id: 1,
    },
  },
]);

Supported aggregation pipeline stages:

  • $addFields
  • $bucket
  • $bucketAuto
  • $collStats
  • $count
  • $densify
  • $fill
  • $facet
  • $geoNear
  • $graphLookup
  • $group
  • $indexStats
  • $limit
  • $listSessions
  • $lookup
  • $match
  • $merge
  • $out
  • $planCacheStats
  • $project
  • $redact
  • $replaceRoot
  • $replaceWith
  • $sample
  • $search
  • $set
  • $setWindowFields
  • $skip
  • $sort
  • $sortByCount
  • $unionWith
  • $unset
  • $unwind
0.3.0

9 months ago

0.3.2

9 months ago

0.4.0

9 months ago

0.3.1

9 months ago

0.2.4

9 months ago

0.2.0

12 months ago

0.2.3

12 months ago

0.1.2-beta

1 year ago

0.1.1-beta

1 year ago

0.1.0-beta

1 year ago