Example #1
0
 /**
  * @param array $filter
  * @param array $options
  *
  * @return Persistable
  */
 public function findOne(array $filter = [], array $options = [])
 {
     $options['typeMap'] = ['root' => 'array', 'document' => 'array', 'array' => 'array'];
     if ($bson = $this->collection->findOne($filter, $options)) {
         return $this->hydrator->hydrate($bson);
     }
 }
Example #2
0
 /**
  * @param array $filter
  * @param array $options
  *
  * @return \Traversable
  */
 public function find(array $filter = [], array $options = [])
 {
     $cursor = $this->collection->find($filter, $options);
     $cursor->setTypeMap(['root' => 'array', 'document' => 'array', 'array' => 'array']);
     foreach ($cursor as $values) {
         (yield $this->hydrator->hydrate($values));
     }
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 public function current()
 {
     return $this->hydrator->hydrate($this->iterator->current());
 }