mirror of
https://github.com/appwrite/appwrite
synced 2026-05-22 08:28:42 +00:00
Merge pull request #11182 from appwrite/chore-make-update-name-optional
This commit is contained in:
commit
0dd2f29a7e
12 changed files with 60 additions and 154 deletions
|
|
@ -6957,8 +6957,7 @@
|
|||
"enabled"
|
||||
],
|
||||
"required": [
|
||||
"databaseId",
|
||||
"name"
|
||||
"databaseId"
|
||||
],
|
||||
"responses": [
|
||||
{
|
||||
|
|
@ -7013,10 +7012,7 @@
|
|||
"description": "Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled.",
|
||||
"x-example": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -7516,10 +7512,7 @@
|
|||
"description": "Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled.",
|
||||
"x-example": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -37112,10 +37105,7 @@
|
|||
"description": "Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled.",
|
||||
"x-example": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -37579,10 +37569,7 @@
|
|||
"description": "Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled.",
|
||||
"x-example": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6427,8 +6427,7 @@
|
|||
"enabled"
|
||||
],
|
||||
"required": [
|
||||
"databaseId",
|
||||
"name"
|
||||
"databaseId"
|
||||
],
|
||||
"responses": [
|
||||
{
|
||||
|
|
@ -6484,10 +6483,7 @@
|
|||
"description": "Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled.",
|
||||
"x-example": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6993,10 +6989,7 @@
|
|||
"description": "Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled.",
|
||||
"x-example": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -26760,10 +26753,7 @@
|
|||
"description": "Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled.",
|
||||
"x-example": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -27232,10 +27222,7 @@
|
|||
"description": "Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled.",
|
||||
"x-example": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6957,8 +6957,7 @@
|
|||
"enabled"
|
||||
],
|
||||
"required": [
|
||||
"databaseId",
|
||||
"name"
|
||||
"databaseId"
|
||||
],
|
||||
"responses": [
|
||||
{
|
||||
|
|
@ -7013,10 +7012,7 @@
|
|||
"description": "Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled.",
|
||||
"x-example": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -7516,10 +7512,7 @@
|
|||
"description": "Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled.",
|
||||
"x-example": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -37112,10 +37105,7 @@
|
|||
"description": "Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled.",
|
||||
"x-example": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -37579,10 +37569,7 @@
|
|||
"description": "Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled.",
|
||||
"x-example": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6427,8 +6427,7 @@
|
|||
"enabled"
|
||||
],
|
||||
"required": [
|
||||
"databaseId",
|
||||
"name"
|
||||
"databaseId"
|
||||
],
|
||||
"responses": [
|
||||
{
|
||||
|
|
@ -6484,10 +6483,7 @@
|
|||
"description": "Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled.",
|
||||
"x-example": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6993,10 +6989,7 @@
|
|||
"description": "Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled.",
|
||||
"x-example": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -26760,10 +26753,7 @@
|
|||
"description": "Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled.",
|
||||
"x-example": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -27232,10 +27222,7 @@
|
|||
"description": "Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled.",
|
||||
"x-example": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7080,8 +7080,7 @@
|
|||
"enabled"
|
||||
],
|
||||
"required": [
|
||||
"databaseId",
|
||||
"name"
|
||||
"databaseId"
|
||||
],
|
||||
"responses": [
|
||||
{
|
||||
|
|
@ -7135,10 +7134,7 @@
|
|||
"default": true,
|
||||
"x-example": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
@ -7634,10 +7630,7 @@
|
|||
"default": true,
|
||||
"x-example": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
@ -37153,10 +37146,7 @@
|
|||
"default": true,
|
||||
"x-example": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
@ -37616,10 +37606,7 @@
|
|||
"default": true,
|
||||
"x-example": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -6534,8 +6534,7 @@
|
|||
"enabled"
|
||||
],
|
||||
"required": [
|
||||
"databaseId",
|
||||
"name"
|
||||
"databaseId"
|
||||
],
|
||||
"responses": [
|
||||
{
|
||||
|
|
@ -6590,10 +6589,7 @@
|
|||
"default": true,
|
||||
"x-example": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
@ -7095,10 +7091,7 @@
|
|||
"default": true,
|
||||
"x-example": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
@ -26857,10 +26850,7 @@
|
|||
"default": true,
|
||||
"x-example": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
@ -27325,10 +27315,7 @@
|
|||
"default": true,
|
||||
"x-example": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -7080,8 +7080,7 @@
|
|||
"enabled"
|
||||
],
|
||||
"required": [
|
||||
"databaseId",
|
||||
"name"
|
||||
"databaseId"
|
||||
],
|
||||
"responses": [
|
||||
{
|
||||
|
|
@ -7135,10 +7134,7 @@
|
|||
"default": true,
|
||||
"x-example": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
@ -7634,10 +7630,7 @@
|
|||
"default": true,
|
||||
"x-example": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
@ -37153,10 +37146,7 @@
|
|||
"default": true,
|
||||
"x-example": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
@ -37616,10 +37606,7 @@
|
|||
"default": true,
|
||||
"x-example": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -6534,8 +6534,7 @@
|
|||
"enabled"
|
||||
],
|
||||
"required": [
|
||||
"databaseId",
|
||||
"name"
|
||||
"databaseId"
|
||||
],
|
||||
"responses": [
|
||||
{
|
||||
|
|
@ -6590,10 +6589,7 @@
|
|||
"default": true,
|
||||
"x-example": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
@ -7095,10 +7091,7 @@
|
|||
"default": true,
|
||||
"x-example": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
@ -26857,10 +26850,7 @@
|
|||
"default": true,
|
||||
"x-example": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
@ -27325,10 +27315,7 @@
|
|||
"default": true,
|
||||
"x-example": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ class Update extends Action
|
|||
))
|
||||
->param('databaseId', '', new UID(), 'Database ID.')
|
||||
->param('collectionId', '', new UID(), 'Collection ID.')
|
||||
->param('name', null, new Text(128), 'Collection name. Max length: 128 chars.')
|
||||
->param('name', null, new Text(128), 'Collection name. Max length: 128 chars.', true)
|
||||
->param('permissions', null, new Nullable(new Permissions(APP_LIMIT_ARRAY_PARAMS_SIZE)), 'An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).', true)
|
||||
->param('documentSecurity', false, new Boolean(true), 'Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions).', true)
|
||||
->param('enabled', true, new Boolean(), 'Is collection enabled? When set to \'disabled\', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled.', true)
|
||||
|
|
@ -75,7 +75,7 @@ class Update extends Action
|
|||
->callback($this->action(...));
|
||||
}
|
||||
|
||||
public function action(string $databaseId, string $collectionId, string $name, ?array $permissions, bool $documentSecurity, bool $enabled, UtopiaResponse $response, Database $dbForProject, Event $queueForEvents, Authorization $authorization): void
|
||||
public function action(string $databaseId, string $collectionId, ?string $name, ?array $permissions, bool $documentSecurity, bool $enabled, UtopiaResponse $response, Database $dbForProject, Event $queueForEvents, Authorization $authorization): void
|
||||
{
|
||||
$database = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId));
|
||||
if ($database->isEmpty()) {
|
||||
|
|
@ -87,6 +87,12 @@ class Update extends Action
|
|||
throw new Exception($this->getNotFoundException(), params: [$collectionId]);
|
||||
}
|
||||
|
||||
if ($name) {
|
||||
$collection = $collection->setAttribute('name', $name);
|
||||
}
|
||||
|
||||
$searchName = $name ?? $collection->getAttribute('name');
|
||||
|
||||
$permissions ??= $collection->getPermissions();
|
||||
|
||||
// Map aggregate permissions into the multiple permissions they represent.
|
||||
|
|
@ -98,11 +104,10 @@ class Update extends Action
|
|||
'database_' . $database->getSequence(),
|
||||
$collectionId,
|
||||
$collection
|
||||
->setAttribute('name', $name)
|
||||
->setAttribute('$permissions', $permissions)
|
||||
->setAttribute('documentSecurity', $documentSecurity)
|
||||
->setAttribute('enabled', $enabled)
|
||||
->setAttribute('search', \implode(' ', [$collectionId, $name]))
|
||||
->setAttribute('search', \implode(' ', [$collectionId, $searchName]))
|
||||
);
|
||||
|
||||
$dbForProject->updateCollection('database_' . $database->getSequence() . '_collection_' . $collection->getSequence(), $permissions, $documentSecurity);
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class Update extends Action
|
|||
),
|
||||
])
|
||||
->param('databaseId', '', new UID(), 'Database ID.')
|
||||
->param('name', null, new Text(128), 'Database name. Max length: 128 chars.')
|
||||
->param('name', null, new Text(128), 'Database name. Max length: 128 chars.', true)
|
||||
->param('enabled', true, new Boolean(), 'Is database enabled? When set to \'disabled\', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled.', true)
|
||||
->inject('response')
|
||||
->inject('dbForProject')
|
||||
|
|
@ -65,7 +65,7 @@ class Update extends Action
|
|||
->callback($this->action(...));
|
||||
}
|
||||
|
||||
public function action(string $databaseId, string $name, bool $enabled, UtopiaResponse $response, Database $dbForProject, Event $queueForEvents): void
|
||||
public function action(string $databaseId, ?string $name, bool $enabled, UtopiaResponse $response, Database $dbForProject, Event $queueForEvents): void
|
||||
{
|
||||
$database = $dbForProject->getDocument('databases', $databaseId);
|
||||
|
||||
|
|
@ -73,10 +73,15 @@ class Update extends Action
|
|||
throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]);
|
||||
}
|
||||
|
||||
if ($name) {
|
||||
$database = $database->setAttribute('name', $name);
|
||||
}
|
||||
|
||||
$searchName = $name ?? $database->getAttribute('name');
|
||||
|
||||
$database = $dbForProject->updateDocument('databases', $databaseId, $database
|
||||
->setAttribute('name', $name)
|
||||
->setAttribute('enabled', $enabled)
|
||||
->setAttribute('search', implode(' ', [$databaseId, $name])));
|
||||
->setAttribute('search', implode(' ', [$databaseId, $searchName])));
|
||||
|
||||
$queueForEvents->setParam('databaseId', $database->getId());
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class Update extends CollectionUpdate
|
|||
))
|
||||
->param('databaseId', '', new UID(), 'Database ID.')
|
||||
->param('tableId', '', new UID(), 'Table ID.')
|
||||
->param('name', null, new Text(128), 'Table name. Max length: 128 chars.')
|
||||
->param('name', null, new Text(128), 'Table name. Max length: 128 chars.', true)
|
||||
->param('permissions', null, new Nullable(new Permissions(APP_LIMIT_ARRAY_PARAMS_SIZE)), 'An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).', true)
|
||||
->param('rowSecurity', false, new Boolean(true), 'Enables configuring permissions for individual rows. A user needs one of row or table-level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions).', true)
|
||||
->param('enabled', true, new Boolean(), 'Is table enabled? When set to \'disabled\', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled.', true)
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ class Update extends DatabaseUpdate
|
|||
contentType: ContentType::JSON
|
||||
))
|
||||
->param('databaseId', '', new UID(), 'Database ID.')
|
||||
->param('name', null, new Text(128), 'Database name. Max length: 128 chars.')
|
||||
->param('name', null, new Text(128), 'Database name. Max length: 128 chars.', true)
|
||||
->param('enabled', true, new Boolean(), 'Is database enabled? When set to \'disabled\', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled.', true)
|
||||
->inject('response')
|
||||
->inject('dbForProject')
|
||||
|
|
|
|||
Loading…
Reference in a new issue