Skip to content

Commit

Permalink
Merge pull request #9 from zumba/map-collection
Browse files Browse the repository at this point in the history
Just wrapping the client collection to copy options
  • Loading branch information
dmatsinger authored Feb 15, 2017
2 parents 55f7df8 + 6394966 commit 4e99268
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions src/Client/Connector.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@ class Connector implements BaseConnector {
*/
protected $connection;

/**
* Array of collection objects keyed by collection name
*
* @var array
*/
protected $collections;

/**
* The db name this connector should work off
*
Expand All @@ -40,7 +33,7 @@ public function __construct(\MongoDB\Client $connection) {
/**
* Retrieves a connection.
*
* @return \MongoClient
* @return \MongoDB\Client
*/
public function getConnection() {
return $this->connection;
Expand All @@ -59,17 +52,10 @@ public function setDb($name = 'test') {
* Retrieves a collection object by name.
*
* @param string $name
* @return \MongoCollection
* @return \MongoDB\Collection
*/
public function collection($name) {
if (empty($this->collections[$name])) {
$this->collections[$name] = new \MongoDB\Collection(
$this->connection->getManager(),
$this->connection->selectDatabase($this->dbName),
$name
);
}
return $this->collections[$name];
return $this->connection->selectCollection($this->dbName, $name);
}

}

0 comments on commit 4e99268

Please sign in to comment.