Execute the find query.

@see Collection::find()
@param array $query
@param array $fields
@return Cursor
977969
protected function doFind(array $query, array $fields)
    {
        $mongoCollection = $this->mongoCollection;
        $cursor = $this->retry(function() use ($mongoCollection, $query, $fields) {
            return $mongoCollection->find($query, $fields);
        });
        return $this->wrapCursor($cursor, $query, $fields);
    }
1205010
final public function queryArrayOne(string $query, string $field = '')
    {
        $result = $this->queryResult($query);
        if (false === $result) {
            return false;
        }

        $return = [];
        $verifiedFieldName = false;
        while ($row = $result->fetchRow()) {
            if ('' === $field) {
                $keys = array_keys($row);
                $field = $keys[0];
                $verifiedFieldName = true;
            }
            if (! $verifiedFieldName) {
                if (! array_key_exists($field, $row)) {
                    return false;
                }
                $verifiedFieldName = true;
            }
            $return[] = $row[$field] ?? null;
        }
        return $return;
    }
1014736
public function findBy($field, $value, $columns = ['*'])
    {
        $this->newQuery();

        return $this->query->where($field, '=', $value)->first($columns);
    }
1356214
public static function select( $table, $fields = array(), $handler = null ) 
	{
		return Query::select( $table, $fields, $handler );
	}
303418
public function query($entity, $query)
	{
		$retValue = array();

		if (! is_null($this->_db)){
			try{
				$mongo = $this->_db->selectCollection($entity);

				// Find by query
				$cursor = $mongo->find($query);

				if (is_null($cursor))
					$retValue = array();
				else
					$retValue = iterator_to_array($cursor);
			}
			catch(Exception $e) {
				$this->_log->addError($e->getMessage());
			}	
		}

		return $retValue;
	}
1249978
protected function doFindOne(array $query, array $fields)
    {
        $mongoCollection = $this->mongoCollection;
        return $this->retry(function() use ($mongoCollection, $query, $fields) {
            return $mongoCollection->findOne($query, $fields);
        });
    }
945960
public function find(array $query = array(), array $fields = array())
    {
        if ($this->eventManager->hasListeners(Events::preFind)) {
            $this->eventManager->dispatchEvent(Events::preFind, new FindEventArgs($this, $query, $fields));
        }

        $result = $this->doFind($query, $fields);

        if ($this->eventManager->hasListeners(Events::postFind)) {
            $eventArgs = new MutableEventArgs($this, $result);
            $this->eventManager->dispatchEvent(Events::postFind, $eventArgs);
            $result = $eventArgs->getData();
        }

        return $result;
    }
1024171
public function findOne($query = [], $fields = [])
    {
        if (is_string($query)) {
            return $this->collection->findOne($query, $fields = []);
        }

        return parent::findOne($query, $fields);
    }
1214782
public function search(string $query, array $arguments = null)
    {
        $args = ['q' => $query];
        if (is_array($arguments)) {
            $args = array_merge($arguments, $args);
        }
        return new SearchIterator($this, 'search/tweets', $args);
    }
165180
public function find($query, $sort = array(), $skip = 0, $limit = 0, $fields = array())
    {
        $cursor = $this->collection->find($query, $fields);
        $count = $cursor->count();
        if (empty($count)) {
            return array();
        }
        if ($sort) $cursor->sort($sort);
        if ($skip) $cursor->skip($skip);
        if ($limit) $cursor->limit($limit);
        return iterator_to_array($cursor);
    }
689115
protected function createMatchQuery($expression, array $fields = [])
    {
        if (0 == strlen($expression)) {
            return new Query\MatchAll();
        }

        if (empty($fields)) {
            $fields = $this->getDefaultMatchFields();
        }

        $query = new Query\MultiMatch();
        $query
            ->setQuery($expression)
            ->setFields($fields);

        return $query;
    }
332965
public function whereMultiMatch(string $query, array $fields, $fuzziness = "auto")
    {
        $param = [
            "multi_match" => [
                "query" => $query,
                "fields" => $fields,
                "fuzziness" => $fuzziness
            ]
        ];
        $this->elasticQuery[] = $param;
        return $this;
    }
1132642
public function find($collectionName, array $criteria = [], array $fields = []) {
		$collection = $this->getCollection($collectionName);
		
		if ($this->_profilerEnabled) {
			$message = 'db.' . $collectionName . '.find(';

			if (empty($criteria)) {
				$message .= ');';
			} else {
				$message .= json_encode($criteria) . ');';
			}

			$event = $this->getProfiler()->startRead($message);
		}

		$cursor = $collection->find($criteria, $fields);

		if ($this->_profilerEnabled) {
			$event->stopSuccess();
		}

		return $cursor;
	}
582620
public function whereTerms(string $field, array $query)
    {
        $param = [
            "terms" => [
                $field => $query
            ]
        ];

        $this->elasticQuery[] = $param;
        return $this;
    }
321126
protected function doFindOne(array $query, array $fields)
    {
        $riakCollection = $this->riakCollection;
        return $this->retry(function() use ($riakCollection, $query, $fields) {
            return $riakCollection->findOne($query, $fields);
        });
    }
446414
public function select(...$fields) {
        $sql = new Query(...$fields);
        $sql->setDialect($this->dialect);

        return $sql;
    }
295925
public function searchCollection($query, CollectionSearchQuery $parameters, array $headers = [])
    {
        $data = $this->getApi()->searchCollection($query, $this->getParameters($parameters), $headers);

        return $this->getCollectionFactory()->createResultCollection($data);
    }