public function read($query, array $options = []) {
		$this->_checkConnection();

		$defaults = ['return' => 'resource'];
		$options += $defaults;

		$params = compact('query', 'options');

		return Filters::run($this, __FUNCTION__, $params, function($params) {
			$prefix = $this->_config['gridPrefix'];

			$query = $params['query'];
			$options = $params['options'];
			$args = $query->export($this);
			$source = $args['source'];
			$model = $query->model();

			if ($group = $args['group']) {
				$result = $this->_group($group, $args, $options);
				$config = ['class' => 'set', 'defaults' => false] + compact('query') + $result;
				return $model::create($config['data'], $config);
			}
			$collection = $this->connection->{$source};

			if ($source === "{$prefix}.files") {
				$collection = $this->connection->getGridFS($prefix);
			}
			$result = $collection->find($args['conditions'], $args['fields']);

			if ($query->calculate()) {
				return $result;
			}

			$resource = $result->sort($args['order'])->limit($args['limit'])->skip($args['offset']);
			$result = $this->_instance('result', compact('resource'));
			$config = compact('result', 'query') + ['class' => 'set', 'defaults' => false];
			return $model::create([], $config);
		});
	}
public function read($query, array $options = []) {
		$this->_checkConnection();

		$defaults = ['return' => 'resource'];
		$options += $defaults;

		$params = compact('query', 'options');

		return Filters::run($this, __FUNCTION__, $params, function($params) {
			$prefix = $this->_config['gridPrefix'];

			$query = $params['query'];
			$options = $params['options'];
			$args = $query->export($this);
			$source = $args['source'];
			$model = $query->model();

			if ($group = $args['group']) {
				$result = $this->_group($group, $args, $options);
				$config = ['class' => 'set', 'defaults' => false] + compact('query') + $result;
				return $model::create($config['data'], $config);
			}
			$collection = $this->connection->{$source};

			if ($source === "{$prefix}.files") {
				$collection = $this->connection->getGridFS($prefix);
			}
			$result = $collection->find($args['conditions'], $args['fields']);

			if ($query->calculate()) {
				return $result;
			}

			$resource = $result->sort($args['order'])->limit($args['limit'])->skip($args['offset']);
			$result = $this->_instance('result', compact('resource'));
			$config = compact('result', 'query') + ['class' => 'set', 'defaults' => false];
			return $model::create([], $config);
		});
	}
public function read ( $ query , array $ options = [ ] ) { $ this -> _checkConnection ( ) ; $ defaults = [ 'return' => 'resource' ] ; $ options += $ defaults ; $ params = compact ( 'query' , 'options' ) ; return Filters :: run ( $ this , __FUNCTION__ , $ params , function ( $ params ) { $ prefix = $ this -> _config [ 'gridPrefix' ] ; $ query = $ params [ 'query' ] ; $ options = $ params [ 'options' ] ; $ args = $ query -> export ( $ this ) ; $ source = $ args [ 'source' ] ; $ model = $ query -> model ( ) ; if ( $ group = $ args [ 'group' ] ) { $ result = $ this -> _group ( $ group , $ args , $ options ) ; $ config = [ 'class' => 'set' , 'defaults' => false ] + compact ( 'query' ) + $ result ; return $ model :: create ( $ config [ 'data' ] , $ config ) ; } $ collection = $ this -> connection -> { $ source } ; if ( $ source === "{$prefix}.files" ) { $ collection = $ this -> connection -> getGridFS ( $ prefix ) ; } $ result = $ collection -> find ( $ args [ 'conditions' ] , $ args [ 'fields' ] ) ; if ( $ query -> calculate ( ) ) { return $ result ; } $ resource = $ result -> sort ( $ args [ 'order' ] ) -> limit ( $ args [ 'limit' ] ) -> skip ( $ args [ 'offset' ] ) ; $ result = $ this -> _instance ( 'result' , compact ( 'resource' ) ) ; $ config = compact ( 'result' , 'query' ) + [ 'class' => 'set' , 'defaults' => false ] ; return $ model :: create ( [ ] , $ config ) ; } ) ; }
Read from document

@param string $query
@param array $options
@return object
@filter
Read from document