mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Allow 'unique()' for nested document IDs
This commit is contained in:
@@ -2739,9 +2739,15 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/documents')
|
||||
fn() => $dbForProject->getDocument('database_' . $database->getInternalId() . '_collection_' . $relatedCollection->getInternalId(), $relation->getId())
|
||||
);
|
||||
|
||||
$type = $current->isEmpty()
|
||||
? Database::PERMISSION_CREATE
|
||||
: Database::PERMISSION_UPDATE;
|
||||
if ($current->isEmpty()) {
|
||||
$type = Database::PERMISSION_CREATE;
|
||||
|
||||
if (isset($relation['$id']) && $relation['$id'] === 'unique()') {
|
||||
$relation['$id'] = ID::unique();
|
||||
}
|
||||
} else {
|
||||
$type = Database::PERMISSION_UPDATE;
|
||||
}
|
||||
|
||||
$checkPermissions($relatedCollection, $relation, $type);
|
||||
}
|
||||
@@ -3304,7 +3310,18 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/documents/:docum
|
||||
'database_' . $database->getInternalId() . '_collection_' . $relatedCollection->getInternalId(),
|
||||
$relation->getId()
|
||||
));
|
||||
$checkPermissions($relatedCollection, $relation, $oldDocument);
|
||||
|
||||
if ($oldDocument->isEmpty()) {
|
||||
$type = Database::PERMISSION_CREATE;
|
||||
|
||||
if (isset($relation['$id']) && $relation['$id'] === 'unique()') {
|
||||
$relation['$id'] = ID::unique();
|
||||
}
|
||||
} else {
|
||||
$type = Database::PERMISSION_UPDATE;
|
||||
}
|
||||
|
||||
$checkPermissions($relatedCollection, $relation, $oldDocument, $type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,7 +217,9 @@ class DatabaseV1 extends Worker
|
||||
throw new Exception('Failed to delete Attribute');
|
||||
}
|
||||
}
|
||||
|
||||
$dbForProject->deleteDocument('attributes', $attribute->getId());
|
||||
|
||||
if (!$relatedAttribute->isEmpty()) {
|
||||
$dbForProject->deleteDocument('attributes', $relatedAttribute->getId());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user