alexpts/php-mongo-repository

Repository for MongoDb

0.3.0 2022-03-02 19:54 UTC

This package is auto-updated.

Last update: 2024-11-29 06:10:11 UTC


README

Build Status Code Coverage Scrutinizer Code Quality

Example

integration tests

<?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