alexpts / php-mongo-repository
Repository for MongoDb
0.3.0
2022-03-02 19:54 UTC
Requires
- php: ~8.1
- ext-mongodb: >=1.12.1
- alexpts/php-data-transformer2: ^6.1
- mongodb/mongodb: ^1.11
Requires (Dev)
- phpunit/phpunit: ^9.5
README
Example
<?php use PTS\DataTransformer\DataTransformer; use PTS\MongoRepo\CollectionManager; use Test\PTS\MongoRepo\src\UserRepo; $collectionManager = new CollectionManager([ 'dsn' => 'mongodb://127.0.0.1:27017/', 'db' => 'test' ]); $mapper = new DataTransformer; $repo = new UserRepo($collectionManager, $mapper); $models = $repo->findModels(['name' => 'alex']); // models $docsAsArray = $models = $repo->find(['name' => 'alex']); // native mongo docs