mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
updated response model and route
This commit is contained in:
1 parent
f3d7e7dcfd
commit
1daf39c737
2 files changed
+26
-1
No files matched your search
@@ -190,7 +190,8 @@ class Create extends Action
|
||||
'enabled' => $enabled,
|
||||
'search' => implode(' ', [$databaseId, $name]),
|
||||
'type' => $this->getDatabaseType(),
|
||||
'database' => $this->getDatabaseDSN($project)
|
||||
'database' => $this->getDatabaseDSN($project),
|
||||
'status' => 'ready',
|
||||
]));
|
||||
} catch (DuplicateException) {
|
||||
throw new Exception(Exception::DATABASE_ALREADY_EXISTS, params: [$databaseId]);
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace Appwrite\Utopia\Response\Model;
|
||||
|
||||
use Appwrite\Utopia\Response;
|
||||
use Appwrite\Utopia\Response\Model;
|
||||
use Utopia\Database\Document;
|
||||
|
||||
class Database extends Model
|
||||
{
|
||||
@@ -46,9 +47,32 @@ class Database extends Model
|
||||
'default' => 'legacy',
|
||||
'example' => 'legacy',
|
||||
'enum' => ['legacy', 'tablesdb', 'documentsdb', 'vectorsdb'],
|
||||
])
|
||||
->addRule('status', [
|
||||
'type' => self::TYPE_ENUM,
|
||||
'description' => 'Database status. Possible values: `provisioning`, `ready` or `failed`',
|
||||
'default' => 'ready',
|
||||
'example' => 'ready',
|
||||
'enum' => ['provisioning', 'ready', 'failed'],
|
||||
'enumSDKName' => 'DatabaseStatus',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* A null status is treated as ready.
|
||||
*
|
||||
* @param Document $document
|
||||
* @return Document
|
||||
*/
|
||||
public function filter(Document $document): Document
|
||||
{
|
||||
if (empty($document->getAttribute('status'))) {
|
||||
$document->setAttribute('status', 'ready');
|
||||
}
|
||||
|
||||
return $document;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Name
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user