-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide option to return a cursor for table row results (#129)
* Give option to return a cursor rather than array * Give option to pass in custom cursor * Get the verbiage correct: we're manipulating the documents * Expose $options parameter on Driver->getTableRows() * Need to abstract out getConfigInstance() for testing downstream * Add the same behavior to the constructor * Add tests * consistent uri
- Loading branch information
Showing
5 changed files
with
176 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace Tripod\Mongo\Documents; | ||
|
||
class Tables extends \MongoDB\Model\BSONDocument | ||
{ | ||
public function __construct(array $input = []) | ||
{ | ||
parent::__construct($this->toTableRow($input)); | ||
} | ||
/** | ||
* Sets the array value to the modeled table row value | ||
* | ||
* @param array $data DB document array | ||
* @return void | ||
*/ | ||
public function bsonUnserialize(array $data) | ||
{ | ||
$this->exchangeArray($this->toTableRow($data)); | ||
} | ||
|
||
/** | ||
* Models the table row from the source data | ||
* | ||
* @param array $doc Database document | ||
* @return array | ||
*/ | ||
protected function toTableRow(array $doc) | ||
{ | ||
$result = isset($doc['value']) ? $doc['value'] : []; | ||
if (isset($result[_IMPACT_INDEX])) { | ||
unset($result[_IMPACT_INDEX]); | ||
} | ||
return $result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters