AggregateMongo pagination adapter uses AggregateCursor
to fetch data from mongo aggregation
pipeline, hydrating objects from current page result set.
namespace Foo\Controllers\Frontend;
use Vegas\Mvc\Controller\ControllerAbstract;
class FooController extends ControllerAbstract
{
public function indexAction()
{
$results = new \Vegas\Paginator\Adapter\AggregateMongo([
'db' => $this->mongo,
'modelName' => '\Foo\Models\Foo', // or 'model' => new FakeModel()
'query' => [
// aggregation pipeline here
]
]);
$this->view->page = $results->getPaginate();
}
}
If not specified, the default elements limit for pagination is 10.
namespace Foo\Controllers\Frontend;
use Vegas\Mvc\Controller\ControllerAbstract;
class FooController extends ControllerAbstract
{
public function indexAction()
{
$results = new \Vegas\Paginator\Adapter\AggregateMongo([
'db' => $this->mongo,
'modelName' => '\Foo\Models\Foo', // or 'model' => new FakeModel()
'limit' => 12,
'page' => $this->request->get('page', 'int', 1),
'query' => [
// aggregation pipeline here
]
]);
$this->view->page = $results->getPaginate();
}
}
The query array is used by MongoCollection::aggregateCursor()
For more details check method reference
here.