dmitrymomot / mongodb-querybuilder
A query builder for mongodb
0.1.2
2017-08-03 13:42 UTC
Requires
- php: ^7.0
- ext-mongodb: ^1.1.0
- mongodb/mongodb: ^1.0
Requires (Dev)
- phpunit/phpunit: ^5.7.4
This package is auto-updated.
Last update: 2024-11-12 23:25:23 UTC
README
A query builder for mongodb
Installation
require this library through composer:
composer require algatux/mongodb-querybuilder:dev-master
##Usage example
/** @var \MongoDB\Collection $mongodbCollection */ $builder = new QueryBuilder($mongodbCollection); /** @var \MongoDB\Driver\Cursor $cursor */ $cursor = $builder ->select('_id', 'field1') // projection ->and( $builder->expr()->or( // $or ['field1' => 'value1'], ['field2' => 'value2'], ), ['field3' => 'value3'] ) // $and ->sort(['field1' => -1]) // sort option ->limit(10) // limit option ->skip(2) // skip option ->setQueryOption('foo', $bar) // adds not actually method supported options ->find() // will trigger $collection->find() method ->getQuery() ->execute();