2017 © Pedro Peláez
 

library mongodb-aggregation-helper

MongoDB help yo biuld aggregation query.

image

ftv/mongodb-aggregation-helper

MongoDB help yo biuld aggregation query.

  • Tuesday, May 10, 2016
  • by lepiaf
  • Repository
  • 12 Watchers
  • 1 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

MongoDB Aggregation helper

This project is part of francetv zoom open source projects (iOS, Android and Angular)., (*1)

Class to help to build mongodb aggregation query., (*2)

Install

In composer.json, (*3)

"repositories": [
    {
        "type": "vcs",
        "url": "git@github.com/francetv/mongodb-aggregation-helper.git"
    }
]

And run composer, (*4)

composer require ftv/mongodb-aggregation-helper

How to use

Create a new instance of Ftv\MongoDB\Aggregation with an instance of \MongoCollection as parameter., (*5)

You can use method to build aggregation. There are chainable., (*6)

$aggregation = $this->createAggregate()
    ->addMatch([
        'groupId' => 'group-id',
        'publication.startDate' => ['$gte' => new \MongoDate() ],
    ])
    ->addSort([['field' => 'updated', "order" => 'desc']])
    ->addProject([
        'slug' => 1,
        'diff' => ['$subtract' => [new \MongoDate(), '$publication.startDate']]
    ]);

Then, execute it., (*7)

$aggregation->execute();

The Versions

10/05 2016

dev-master

9999999-dev

MongoDB help yo biuld aggregation query.

  Sources   Download

MIT

The Development Requires

mongodb aggregation