mirror of
https://github.com/appwrite/appwrite
synced 2026-05-23 17:08:45 +00:00
update db name
This commit is contained in:
parent
ba83dd9252
commit
85656f81a5
5 changed files with 30 additions and 30 deletions
|
|
@ -41,13 +41,13 @@ class CreateKey extends Action
|
|||
->param('name', null, new Text(128), 'Key name. Max length: 128 chars.')
|
||||
->param('expire', null, new DatetimeValidator(), 'Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format.', false)
|
||||
->inject('response')
|
||||
->inject('dbForConsole')
|
||||
->callback(fn ($projectId, $name, $expire, $response, $dbForConsole) => $this->action($projectId, $name, $expire, $response, $dbForConsole));
|
||||
->inject('dbForPlatform')
|
||||
->callback(fn ($projectId, $name, $expire, $response, $dbForPlatform) => $this->action($projectId, $name, $expire, $response, $dbForPlatform));
|
||||
}
|
||||
|
||||
public function action(string $projectId, string $name, ?string $expire, Response $response, Database $dbForConsole)
|
||||
public function action(string $projectId, string $name, ?string $expire, Response $response, Database $dbForPlatform)
|
||||
{
|
||||
$project = $dbForConsole->getDocument('projects', $projectId);
|
||||
$project = $dbForPlatform->getDocument('projects', $projectId);
|
||||
|
||||
if ($project->isEmpty()) {
|
||||
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
||||
|
|
@ -69,9 +69,9 @@ class CreateKey extends Action
|
|||
'secret' => \bin2hex(\random_bytes(128)),
|
||||
]);
|
||||
|
||||
$key = $dbForConsole->createDocument('devKeys', $key);
|
||||
$key = $dbForPlatform->createDocument('devKeys', $key);
|
||||
|
||||
$dbForConsole->purgeCachedDocument('projects', $project->getId());
|
||||
$dbForPlatform->purgeCachedDocument('projects', $project->getId());
|
||||
|
||||
$response
|
||||
->setStatusCode(Response::STATUS_CODE_CREATED)
|
||||
|
|
|
|||
|
|
@ -34,20 +34,20 @@ class DeleteKey extends Action
|
|||
->param('projectId', '', new UID(), 'Project unique ID.')
|
||||
->param('keyId', '', new UID(), 'Key unique ID.')
|
||||
->inject('response')
|
||||
->inject('dbForConsole')
|
||||
->callback(fn ($projectId, $keyId, $response, $dbForConsole) => $this->action($projectId, $keyId, $response, $dbForConsole));
|
||||
->inject('dbForPlatform')
|
||||
->callback(fn ($projectId, $keyId, $response, $dbForPlatform) => $this->action($projectId, $keyId, $response, $dbForPlatform));
|
||||
}
|
||||
|
||||
public function action(string $projectId, string $keyId, Response $response, Database $dbForConsole)
|
||||
public function action(string $projectId, string $keyId, Response $response, Database $dbForPlatform)
|
||||
{
|
||||
|
||||
$project = $dbForConsole->getDocument('projects', $projectId);
|
||||
$project = $dbForPlatform->getDocument('projects', $projectId);
|
||||
|
||||
if ($project->isEmpty()) {
|
||||
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
||||
}
|
||||
|
||||
$key = $dbForConsole->findOne('devKeys', [
|
||||
$key = $dbForPlatform->findOne('devKeys', [
|
||||
Query::equal('$id', [$keyId]),
|
||||
Query::equal('projectInternalId', [$project->getInternalId()]),
|
||||
]);
|
||||
|
|
@ -56,9 +56,9 @@ class DeleteKey extends Action
|
|||
throw new Exception(Exception::KEY_NOT_FOUND);
|
||||
}
|
||||
|
||||
$dbForConsole->deleteDocument('devKeys', $key->getId());
|
||||
$dbForPlatform->deleteDocument('devKeys', $key->getId());
|
||||
|
||||
$dbForConsole->purgeCachedDocument('projects', $project->getId());
|
||||
$dbForPlatform->purgeCachedDocument('projects', $project->getId());
|
||||
|
||||
$response->noContent();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,20 +35,20 @@ class GetKey extends Action
|
|||
->param('projectId', '', new UID(), 'Project unique ID.')
|
||||
->param('keyId', '', new UID(), 'Key unique ID.')
|
||||
->inject('response')
|
||||
->inject('dbForConsole')
|
||||
->callback(fn ($projectId, $keyId, $response, $dbForConsole) => $this->action($projectId, $keyId, $response, $dbForConsole));
|
||||
->inject('dbForPlatform')
|
||||
->callback(fn ($projectId, $keyId, $response, $dbForPlatform) => $this->action($projectId, $keyId, $response, $dbForPlatform));
|
||||
}
|
||||
|
||||
public function action(string $projectId, string $keyId, Response $response, Database $dbForConsole)
|
||||
public function action(string $projectId, string $keyId, Response $response, Database $dbForPlatform)
|
||||
{
|
||||
|
||||
$project = $dbForConsole->getDocument('projects', $projectId);
|
||||
$project = $dbForPlatform->getDocument('projects', $projectId);
|
||||
|
||||
if ($project->isEmpty()) {
|
||||
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
||||
}
|
||||
|
||||
$key = $dbForConsole->findOne('devKeys', [
|
||||
$key = $dbForPlatform->findOne('devKeys', [
|
||||
Query::equal('$id', [$keyId]),
|
||||
Query::equal('projectInternalId', [$project->getInternalId()]),
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -35,20 +35,20 @@ class ListKeys extends Action
|
|||
->label('sdk.response.model', Response::MODEL_DEV_KEY_LIST)
|
||||
->param('projectId', '', new UID(), 'Project unique ID.')
|
||||
->inject('response')
|
||||
->inject('dbForConsole')
|
||||
->callback(fn ($projectId, $response, $dbForConsole) => $this->action($projectId, $response, $dbForConsole));
|
||||
->inject('dbForPlatform')
|
||||
->callback(fn ($projectId, $response, $dbForPlatform) => $this->action($projectId, $response, $dbForPlatform));
|
||||
}
|
||||
|
||||
public function action(string $projectId, Response $response, Database $dbForConsole)
|
||||
public function action(string $projectId, Response $response, Database $dbForPlatform)
|
||||
{
|
||||
|
||||
$project = $dbForConsole->getDocument('projects', $projectId);
|
||||
$project = $dbForPlatform->getDocument('projects', $projectId);
|
||||
|
||||
if ($project->isEmpty()) {
|
||||
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
||||
}
|
||||
|
||||
$keys = $dbForConsole->find('devKeys', [
|
||||
$keys = $dbForPlatform->find('devKeys', [
|
||||
Query::equal('projectInternalId', [$project->getInternalId()]),
|
||||
Query::limit(5000),
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -38,19 +38,19 @@ class UpdateKey extends Action
|
|||
->param('name', null, new Text(128), 'Key name. Max length: 128 chars.')
|
||||
->param('expire', null, new DatetimeValidator(), 'Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format.')
|
||||
->inject('response')
|
||||
->inject('dbForConsole')
|
||||
->callback(fn ($projectId, $keyId, $name, $expire, $response, $dbForConsole) => $this->action($projectId, $keyId, $name, $expire, $response, $dbForConsole));
|
||||
->inject('dbForPlatform')
|
||||
->callback(fn ($projectId, $keyId, $name, $expire, $response, $dbForPlatform) => $this->action($projectId, $keyId, $name, $expire, $response, $dbForPlatform));
|
||||
}
|
||||
public function action(string $projectId, string $keyId, string $name, ?string $expire, Response $response, Database $dbForConsole)
|
||||
public function action(string $projectId, string $keyId, string $name, ?string $expire, Response $response, Database $dbForPlatform)
|
||||
{
|
||||
|
||||
$project = $dbForConsole->getDocument('projects', $projectId);
|
||||
$project = $dbForPlatform->getDocument('projects', $projectId);
|
||||
|
||||
if ($project->isEmpty()) {
|
||||
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
||||
}
|
||||
|
||||
$key = $dbForConsole->findOne('devKeys', [
|
||||
$key = $dbForPlatform->findOne('devKeys', [
|
||||
Query::equal('$id', [$keyId]),
|
||||
Query::equal('projectInternalId', [$project->getInternalId()]),
|
||||
]);
|
||||
|
|
@ -63,9 +63,9 @@ class UpdateKey extends Action
|
|||
->setAttribute('name', $name)
|
||||
->setAttribute('expire', $expire);
|
||||
|
||||
$dbForConsole->updateDocument('devKeys', $key->getId(), $key);
|
||||
$dbForPlatform->updateDocument('devKeys', $key->getId(), $key);
|
||||
|
||||
$dbForConsole->purgeCachedDocument('projects', $project->getId());
|
||||
$dbForPlatform->purgeCachedDocument('projects', $project->getId());
|
||||
|
||||
$response->dynamic($key, Response::MODEL_DEV_KEY);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue