mirror of
https://github.com/appwrite/appwrite
synced 2026-05-24 09:28:40 +00:00
update: request, response filters.
This commit is contained in:
parent
3a8f097c17
commit
86d195c1c0
2 changed files with 26 additions and 8 deletions
|
|
@ -6,20 +6,36 @@ use Appwrite\Utopia\Request\Filter;
|
||||||
|
|
||||||
class V19 extends Filter
|
class V19 extends Filter
|
||||||
{
|
{
|
||||||
|
// Map old params to new
|
||||||
|
private const PARAMS_MAP = [
|
||||||
|
'documentId' => 'rowId',
|
||||||
|
'attributes' => 'columns',
|
||||||
|
'collectionId' => 'tableId',
|
||||||
|
'attributeId' => 'columnId',
|
||||||
|
'$collectionId' => '$tableId',
|
||||||
|
'relatedCollection' => 'relatedTable',
|
||||||
|
'relatedCollectionId' => 'relatedTableId',
|
||||||
|
];
|
||||||
|
|
||||||
// Convert 1.6 params to 1.7
|
// Convert 1.6 params to 1.7
|
||||||
public function parse(array $content, string $model): array
|
public function parse(array $content, string $model): array
|
||||||
{
|
{
|
||||||
return match ($model) {
|
$content = $this->overrideDatabaseParams($content, $model);
|
||||||
'databases.createRelationshipColumn' => $this->convertV16RelationshipParams($content),
|
|
||||||
default => $content
|
return $content;
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function convertV16RelationshipParams(array $content): array
|
protected function overrideDatabaseParams(array $content, string $model): array
|
||||||
{
|
{
|
||||||
if (isset($content['relatedCollectionId'])) {
|
if (!str_starts_with($model, 'databases.')) {
|
||||||
$content['relatedTableId'] = $content['relatedCollectionId'];
|
return $content;
|
||||||
unset($content['relatedCollectionId']);
|
}
|
||||||
|
|
||||||
|
$intersect = array_intersect_key(self::PARAMS_MAP, $content);
|
||||||
|
|
||||||
|
foreach ($intersect as $oldKey => $newKey) {
|
||||||
|
$content[$newKey] = $content[$oldKey];
|
||||||
|
unset($content[$oldKey]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $content;
|
return $content;
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,10 @@ class V19 extends Filter
|
||||||
private const DATABASE_MAPPINGS = [
|
private const DATABASE_MAPPINGS = [
|
||||||
'table' => 'collection',
|
'table' => 'collection',
|
||||||
'tables' => 'collections',
|
'tables' => 'collections',
|
||||||
|
'$tableId' => '$collectionId',
|
||||||
'tablesTotal' => 'collectionsTotal',
|
'tablesTotal' => 'collectionsTotal',
|
||||||
'relatedTable' => 'relatedCollection',
|
'relatedTable' => 'relatedCollection',
|
||||||
|
'relatedTableId' => 'relatedCollectionId',
|
||||||
|
|
||||||
'column' => 'attribute',
|
'column' => 'attribute',
|
||||||
'columns' => 'attributes',
|
'columns' => 'attributes',
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue