1.0.11 • Published 4 years ago

mongo-pipeline v1.0.11

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

Mongo aggregation pipeline

This module provide a nice way to work with aggregations of mongodb using, for example, the mongoose in nodejs.

Basic example

const mongoose = require('mongoose');
const { PipelineBuilder } = require('mongo-pipeline');

const pipeline = new PipelineBuilder();

const collection = await pipeline
  .match({ _id: mongoose.Types.ObjectID('xxxxxxxxxxxxxxxxxxx') })
  .lookupAndUnwind('collections', 'field', '_id', 'new')
  .log()
  .aggregateOneWith(mongoose.model('Collection'));
/*
[
  {
    $match: {
      _id: 'xxxxxxxxxxxxxxxxxxx'
    }
  },
  {
    "$lookup": {
      "from": "collections",
      "localField": "field",
      "foreignField": "_id",
      "as": "new"
    }
  },
  {
    "$unwind": {
      "path": "$new"
    }
  }
]
*/

See others examples in test repository.

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago