feat: remove queries

This commit is contained in:
Christy Jacob 2022-08-22 14:12:52 +00:00
parent 3fe22b7ed0
commit 0304a57915
2 changed files with 0 additions and 89 deletions

View file

@ -1,58 +0,0 @@
<?php
namespace Appwrite\Utopia\Database\Validator\Queries;
use Utopia\Config\Config;
use Utopia\Database\Database;
use Utopia\Database\Document;
use Utopia\Database\Validator\Queries as QueriesValidator;
use Utopia\Database\Validator\Query as QueryValidator;
class Collection extends QueriesValidator
{
/**
* Expression constructor
*
* @param string $collection
* @param string[] $allowedAttributes
*/
public function __construct(string $collection, array $allowedAttributes)
{
$collection = Config::getParam('collections', [])[$collection];
// array for constant lookup time
$allowedAttributesLookup = [];
foreach ($allowedAttributes as $attribute) {
$allowedAttributesLookup[$attribute] = true;
}
$attributes = [];
foreach ($collection['attributes'] as $attribute) {
$key = $attribute['$id'];
if (!isset($allowedAttributesLookup[$key])) {
continue;
}
$attributes[] = new Document([
'key' => $key,
'type' => $attribute['type'],
'array' => $attribute['array'],
]);
}
$indexes = [];
foreach ($allowedAttributes as $attribute) {
$indexes[] = new Document([
'status' => 'available',
'type' => Database::INDEX_KEY,
'attributes' => [$attribute]
]);
}
$indexes[] = new Document([
'status' => 'available',
'type' => Database::INDEX_FULLTEXT,
'attributes' => ['search']
]);
parent::__construct(new QueryValidator($attributes), $attributes, $indexes, true);
}
}

View file

@ -1,31 +0,0 @@
<?php
namespace Appwrite\Utopia\Database\Validator\Queries;
use Appwrite\Utopia\Database\Validator\Queries\Collection;
class Users extends Collection
{
public const ALLOWED_ATTRIBUTES = [
'$id',
'$createdAt',
'$updatedAt',
'name',
'email',
'phone',
'status',
'passwordUpdate',
'registration',
'emailVerification',
'phoneVerification',
];
/**
* Expression constructor
*
*/
public function __construct()
{
parent::__construct('users', self::ALLOWED_ATTRIBUTES);
}
}