Mongolid\Cursor\Cursor::getCursor PHP Method

getCursor() protected method

If it does not exists yet, create it using the $collection, $command and $params given.
protected getCursor ( ) : Traversable
return Traversable
    protected function getCursor() : Traversable
    {
        if (!$this->cursor) {
            $params = $this->getConverter()->toMongoTypes($this->params);
            $driverCursor = $this->collection->{$this->command}(...$params);
            $this->cursor = new IteratorIterator($driverCursor);
            $this->cursor->rewind();
        }
        return $this->cursor;
    }

Usage Example

 /**
  * Returns the DriverCursor considering the documents that have already
  * been retrieved from cache.
  *
  * @return Traversable
  */
 protected function getOriginalCursor() : Traversable
 {
     if ($this->ignoreCache) {
         return parent::getCursor();
     }
     if ($this->getLimit()) {
         $this->params[1]['limit'] = $this->getLimit() - $this->position;
     }
     $skipped = $this->params[1]['skip'] ?? 0;
     $this->skip($skipped + $this->position - 1);
     $this->ignoreCache = true;
     return $this->getOriginalCursor();
 }