Fix bug with list documents and new queries
This commit is contained in:
parent
2bde7aa02b
commit
e70eb61717
|
@ -2027,15 +2027,34 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/documents')
|
||||||
throw new Exception(Exception::USER_UNAUTHORIZED);
|
throw new Exception(Exception::USER_UNAUTHORIZED);
|
||||||
}
|
}
|
||||||
|
|
||||||
$filterQueries = \array_map(function ($query) {
|
if (!empty($queries)) {
|
||||||
$query = Query::parse($query);
|
$attributes = array_merge(
|
||||||
|
$collection->getAttribute('attributes', []),
|
||||||
if (\count($query->getValues()) > 100) {
|
[
|
||||||
throw new Exception(Exception::GENERAL_QUERY_LIMIT_EXCEEDED, "You cannot use more than 100 query values on attribute '{$query->getAttribute()}'");
|
new Document([
|
||||||
|
'key' => '$id',
|
||||||
|
'type' => Database::VAR_STRING,
|
||||||
|
'array' => false,
|
||||||
|
]),
|
||||||
|
new Document([
|
||||||
|
'key' => '$createdAt',
|
||||||
|
'type' => Database::VAR_DATETIME,
|
||||||
|
'array' => false,
|
||||||
|
]),
|
||||||
|
new Document([
|
||||||
|
'key' => '$updatedAt',
|
||||||
|
'type' => Database::VAR_DATETIME,
|
||||||
|
'array' => false,
|
||||||
|
]),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
$validator = new IndexedQueries(new LimitOffsetCursorFilterOrderQuery(attributes: $attributes), $attributes, $collection->getAttribute('indexes', []));
|
||||||
|
if (!$validator->isValid($queries)) {
|
||||||
|
throw new Exception(Exception::GENERAL_QUERY_INVALID, $validator->getDescription());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $query;
|
$filterQueries = Query::parseQueries($queries);
|
||||||
}, $queries);
|
|
||||||
|
|
||||||
$otherQueries = [];
|
$otherQueries = [];
|
||||||
$otherQueries[] = Query::limit($limit);
|
$otherQueries[] = Query::limit($limit);
|
||||||
|
@ -2059,14 +2078,6 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/documents')
|
||||||
|
|
||||||
$allQueries = \array_merge($filterQueries, $otherQueries);
|
$allQueries = \array_merge($filterQueries, $otherQueries);
|
||||||
|
|
||||||
if (!empty($allQueries)) {
|
|
||||||
$attributes = $collection->getAttribute('attributes', []);
|
|
||||||
$validator = new IndexedQueries(new LimitOffsetCursorFilterOrderQuery(attributes: $attributes), $attributes, $collection->getAttribute('indexes', []));
|
|
||||||
if (!$validator->isValid($allQueries)) {
|
|
||||||
throw new Exception(Exception::GENERAL_QUERY_INVALID, $validator->getDescription());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($documentSecurity) {
|
if ($documentSecurity) {
|
||||||
$documents = $dbForProject->find('database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId(), $allQueries);
|
$documents = $dbForProject->find('database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId(), $allQueries);
|
||||||
$total = $dbForProject->count('database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId(), $filterQueries, APP_LIMIT_COUNT);
|
$total = $dbForProject->count('database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId(), $filterQueries, APP_LIMIT_COUNT);
|
||||||
|
|
Loading…
Reference in a new issue