Get tailable cursor for query

@param  array  $filters Filters of query
@param  array  $options Option (Tailable setted as default)
@return \MongoDB\Driver\TailableCursor          A tailable cursor
976040
public function getTailableCursor($filters = [], $options = [])
    {
        $options['cursorType'] = \MongoDB\Operation\Find::TAILABLE_AWAIT;

        return $this->collection->find($this->castQuery($filters), $options);
    }
217091
public function execute(array $options = []) : Iterator
    {
        // Force cursor to be used
        $options = array_merge($options, ['cursor' => true]);

        $cursor = $this->collection->aggregate($this->getPipeline(), $options);
        assert($cursor instanceof Cursor);

        return $this->prepareIterator($cursor);
    }
1224430
public function deleteMany(array $filter, array $options = [])
    {
        list($bulkOptions, $options) = self::extractBulkWriteOptions($options);
        $model = new DeleteMany($filter, $options);
        $bulkWriteResult = $this->bulkWrite([$model], $bulkOptions);

        return new DeleteResult($bulkWriteResult);
    }
26436
public function searchUsers(array $filters, array $options = [])
    {
        $data = [
            'body' => $filters
        ];

        $scrollId = null;

        $response = $this->kuzzle->query(
            $this->buildQueryArgs('searchUsers'),
            $data,
            $options
        );

        $response['result']['hits'] = array_map(function ($user) {
            return new User($this, $user['_id'], $user['_source'], $user['_meta']);
        }, $response['result']['hits']);

        if (isset($response['result']['scrollId'])) {
            $scrollId = $response['result']['scrollId'];
        }

        return new UsersSearchResult($response['result']['total'], $response['result']['hits'], $scrollId);
    }
972140
public function getOption($option, $filters = null, $defaultValue = null)
    {
        if (is_array($option)) {
            foreach ($option as $optionItem) {
                if (isset($this->_parameters[$optionItem])) {
                    if ($filters !== null) {
                        return $this->filter($this->_parameters[$optionItem], $filters);
                    }

                    return $this->_parameters[$optionItem];
                }
            }

            return $defaultValue;
        }

        if (isset($this->_parameters[$option])) {
            if ($filters !== null) {
                return $this->filter($this->_parameters[$option], $filters);
            }

            return $this->_parameters[$option];
        }

        return $defaultValue;
    }
741805
public function deleteDocument($filters, array $options = [])
    {
        $data = [];

        if (is_string($filters)) {
            $data['_id'] = $filters;
            $action = 'delete';
        } else {
            $data['body'] = ['query' => (object)$filters];
            $action = 'deleteByQuery';
        }

        $response = $this->kuzzle->query(
            $this->buildQueryArgs('document', $action),
            $this->kuzzle->addHeaders($data, $this->headers),
            $options
        );

        return $action === 'delete' ? $response['result']['_id'] : $response['result']['ids'];
    }
1187259
public function find($filter = NULL, array $options = NULL, $ttl = 0) {
		$sort=false;
		if ($this->dbsType!='sql') {
			// see if reordering is needed
			foreach($this->countFields?:[] as $counter) {
				if ($options && isset($options['order']) &&
					preg_match('/count_'.$counter.'\h+(asc|desc)/i',$options['order'],$match))
					$sort=true;
			}
			if ($sort) {
				// backup slice settings
				if (isset($options['limit'])) {
					$limit = $options['limit'];
					unset($options['limit']);
				}
				if (isset($options['offset'])) {
					$offset = $options['offset'];
					unset($options['offset']);
				}
			}
		}
		$this->_ttl=$ttl?:$this->rel_ttl;
		$result = $this->filteredFind($filter,$options,$ttl);
		if (empty($result))
			return false;
		foreach($result as &$record) {
			$record = $this->factory($record);
			unset($record);
		}
		// add counter for NoSQL engines
		foreach($this->countFields?:[] as $counter)
			foreach($result as &$mapper) {
				$cr=$mapper->get($counter);
				$mapper->virtual('count_'.$counter,$cr?count($cr):null);
				unset($mapper);
			}
		$cc = new CortexCollection();
		$cc->setModels($result);
		if($sort) {
			$cc->orderBy($options['order']);
			$cc->slice(isset($offset)?$offset:0,isset($limit)?$limit:NULL);
		}
		$this->clearFilter();
		return $cc;
	}
750162
public function findOne(array $filter = [], array $options = [])
    {
        $cursor = $this->find($filter, ['limit' => 1] + $options);

        return ($document = $cursor->current()) ? $document : null;
    }
500263
public function withFilters(array $filters = null)
    {
        if ($filters) {
            foreach ($filters as $filter) {
                switch ($filter['type']) {
                    case 'select':
                        $this->select($filter['fields']);
                        break;
                    case 'andWhere':
                        $this->andWhere($filter['field'], $filter['operation'], $filter['value']);
                        break;
                    case 'orWhere':
                        $this->orWhere($filter['field'], $filter['operation'], $filter['value']);
                        break;
                    case 'andHaving':
                        $this->andHaving($filter['field'], $filter['operation'], $filter['value']);
                        break;
                    case 'orHaving':
                        $this->orHaving($filter['field'], $filter['operation'], $filter['value']);
                        break;
                    case 'addGroupBy':
                        $this->addGroupBy($filter['field']);
                        break;
                    case 'addOrderBy':
                        $this->addOrderBy($filter['field'], $filter['order']);
                        break;
                    case 'fkAddOrderBy':
                        $this->fkAddOrderBy($filter['field'], $filter['fkField'], $filter['order']);
                        break;
                    case 'paginate':
                        if (isset($filter['page'])) {
                            $this->paginate($filter['limit'], $filter['page']);
                        } else {
                            $this->paginate($filter['limit']);
                        }
                        break;
                }
            }
        }

        return $this;
    }
1280778
public function getAllUsers($options = [], $filters = [GenerisRdf::PROPERTY_USER_LOGIN => '*'])
    {
        $userClass = new core_kernel_classes_Class(TaoOntology::CLASS_URI_TAO_USER);
		$options = array_merge(['recursive' => true, 'like' => true], $options);

		return (array) $userClass->searchInstances($filters, $options);
    }
649484
public static function get_record($filters = array()) {
        global $DB;

        $record = $DB->get_record(static::TABLE, $filters);
        return $record ? new static(0, $record) : false;
    }
1180222
public function addFiltersWithAndToTable(iterable $filters): self
    {
        $addWith = $this->expr()->andX();
        $this->applyFilters($addWith, $this->getTableName(), $filters);
        $addWith->count() <= 0 ?: $this->andWhere($addWith);

        return $this;
    }
384345
public static function aggregate($filters, $aggregation, $options = null)
    {
        if (is_string($options)) {
            $options = ['group' => $options];
        }
        return static::query()->where($filters)->options($options)->aggregate($aggregation);
    }
985283
public function getRecords($filters = array())
	{
		$entries = self::all();

		$c = $entries->getTableName();
		$e = '#__extensions';

		$entries
			->select($c . '.*,' . $e . '.name')
			->join($e, $e . '.element', $c . '.component', 'inner')
			->whereEquals($e . '.type', 'component');

		if (isset($filters['component']) && $filters['component'])
		{
			$entries->whereEquals($e . '.element', $filters['component']);
		}

		return $entries
			->ordered($c . '.component', 'asc')
			->rows();
	}
1094087
public function setFilters($filters = [])
    {
        foreach ($filters as $field => $rules) {
            if ($field === 'fullSearch') {
                $this->addFilter($field, $rules, null);
                continue;
            }

            if (is_a($rules, MultiFullTextFilter::class)) {
                $this->addFilter($field, $rules, null);
                continue;
            }

            foreach ($rules as $operator => $value) {
                if (!in_array($operator, $this->availableFilters) || (empty($value) && $value != '0')) {
                    continue;
                }
                $this->addFilter($field, $value, $operator);
            }
        }

        return $this;
    }
626488
public function getOptions($filters = null)
    {
        if (!$filters) {
            return $this->_parameters;
        }

        $result = [];

        foreach ($this->_parameters as $param) {
            $result[] = $this->filter($param, $filters);
        }

        return $result;
    }
1352806
public function searchProfiles(array $filters, array $options = [])
    {
        $data = [
            'body' => $filters
        ];

        $scrollId = null;

        $response = $this->kuzzle->query(
            $this->buildQueryArgs('searchProfiles'),
            $data,
            $options
        );

        $response['result']['hits'] = array_map(function ($profile) {
            return new Profile($this, $profile['_id'], $profile['_source'], $profile['_meta']);
        }, $response['result']['hits']);

        if (isset($response['result']['scrollId'])) {
            $scrollId = $response['result']['scrollId'];
        }

        return new ProfilesSearchResult($response['result']['total'], $response['result']['hits'], $scrollId);
    }