mirror of
https://github.com/appwrite/appwrite
synced 2026-05-16 21:48:45 +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
|
||||
{
|
||||
// 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
|
||||
public function parse(array $content, string $model): array
|
||||
{
|
||||
return match ($model) {
|
||||
'databases.createRelationshipColumn' => $this->convertV16RelationshipParams($content),
|
||||
default => $content
|
||||
};
|
||||
$content = $this->overrideDatabaseParams($content, $model);
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
protected function convertV16RelationshipParams(array $content): array
|
||||
protected function overrideDatabaseParams(array $content, string $model): array
|
||||
{
|
||||
if (isset($content['relatedCollectionId'])) {
|
||||
$content['relatedTableId'] = $content['relatedCollectionId'];
|
||||
unset($content['relatedCollectionId']);
|
||||
if (!str_starts_with($model, 'databases.')) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
$intersect = array_intersect_key(self::PARAMS_MAP, $content);
|
||||
|
||||
foreach ($intersect as $oldKey => $newKey) {
|
||||
$content[$newKey] = $content[$oldKey];
|
||||
unset($content[$oldKey]);
|
||||
}
|
||||
|
||||
return $content;
|
||||
|
|
|
|||
|
|
@ -10,8 +10,10 @@ class V19 extends Filter
|
|||
private const DATABASE_MAPPINGS = [
|
||||
'table' => 'collection',
|
||||
'tables' => 'collections',
|
||||
'$tableId' => '$collectionId',
|
||||
'tablesTotal' => 'collectionsTotal',
|
||||
'relatedTable' => 'relatedCollection',
|
||||
'relatedTableId' => 'relatedCollectionId',
|
||||
|
||||
'column' => 'attribute',
|
||||
'columns' => 'attributes',
|
||||
|
|
|
|||
Loading…
Reference in a new issue