lint fix
This commit is contained in:
parent
d6f4d76807
commit
860e9958c7
1 changed files with 18 additions and 18 deletions
|
@ -3252,7 +3252,7 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/documents/:docum
|
||||||
$data['$permissions'] = $permissions;
|
$data['$permissions'] = $permissions;
|
||||||
$newDocument = new Document($data);
|
$newDocument = new Document($data);
|
||||||
|
|
||||||
$setCollection = function (Document $collection, Document $document) use (&$setCollection, $dbForProject, $database) {
|
$setCollection = (function (Document $collection, Document $document) use (&$setCollection, $dbForProject, $database) {
|
||||||
$relationships = \array_filter(
|
$relationships = \array_filter(
|
||||||
$collection->getAttribute('attributes', []),
|
$collection->getAttribute('attributes', []),
|
||||||
fn($attribute) => $attribute->getAttribute('type') === Database::VAR_RELATIONSHIP
|
fn($attribute) => $attribute->getAttribute('type') === Database::VAR_RELATIONSHIP
|
||||||
|
@ -3316,26 +3316,26 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/documents/:docum
|
||||||
$document->setAttribute($relationship->getAttribute('key'), \reset($relations));
|
$document->setAttribute($relationship->getAttribute('key'), \reset($relations));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
$setCollection($collection, $newDocument);
|
$setCollection($collection, $newDocument);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$document = $dbForProject->withRequestTimestamp(
|
$document = $dbForProject->withRequestTimestamp(
|
||||||
$requestTimestamp,
|
$requestTimestamp,
|
||||||
fn() => $dbForProject->updateDocument(
|
fn() => $dbForProject->updateDocument(
|
||||||
'database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId(),
|
'database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId(),
|
||||||
$document->getId(),
|
$document->getId(),
|
||||||
$newDocument
|
$newDocument
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
} catch (AuthorizationException) {
|
} catch (AuthorizationException) {
|
||||||
throw new Exception(Exception::USER_UNAUTHORIZED);
|
throw new Exception(Exception::USER_UNAUTHORIZED);
|
||||||
} catch (DuplicateException) {
|
} catch (DuplicateException) {
|
||||||
throw new Exception(Exception::DOCUMENT_ALREADY_EXISTS);
|
throw new Exception(Exception::DOCUMENT_ALREADY_EXISTS);
|
||||||
} catch (StructureException $exception) {
|
} catch (StructureException $exception) {
|
||||||
throw new Exception(Exception::DOCUMENT_INVALID_STRUCTURE, $exception->getMessage());
|
throw new Exception(Exception::DOCUMENT_INVALID_STRUCTURE, $exception->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add $collectionId and $databaseId for all documents
|
// Add $collectionId and $databaseId for all documents
|
||||||
$processDocument = function (Document $collection, Document $document) use (&$processDocument, $dbForProject, $database) {
|
$processDocument = function (Document $collection, Document $document) use (&$processDocument, $dbForProject, $database) {
|
||||||
|
|
Loading…
Reference in a new issue