deleteByGroup
This commit is contained in:
parent
0f1872cb5a
commit
2391ba07df
|
@ -503,6 +503,7 @@ class Databases extends Action
|
||||||
* @throws DatabaseException
|
* @throws DatabaseException
|
||||||
* @throws Restricted
|
* @throws Restricted
|
||||||
* @throws Structure
|
* @throws Structure
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
protected function deleteCollection(Document $database, Document $collection, Document $project, Database $dbForProject): void
|
protected function deleteCollection(Document $database, Document $collection, Document $project, Database $dbForProject): void
|
||||||
{
|
{
|
||||||
|
@ -518,20 +519,22 @@ class Databases extends Action
|
||||||
/**
|
/**
|
||||||
* Related collections relating to current collection
|
* Related collections relating to current collection
|
||||||
*/
|
*/
|
||||||
$attributes = $dbForProject->find('attributes', [
|
$this->deleteByGroup(
|
||||||
Query::equal('databaseInternalId', [$databaseInternalId]),
|
'attributes',
|
||||||
Query::equal('type', [Database::VAR_RELATIONSHIP]),
|
[
|
||||||
Query::notEqual('collectionInternalId', $collectionInternalId),
|
Query::equal('databaseInternalId', [$databaseInternalId]),
|
||||||
Query::contains('options', ['"relatedCollection":"'. $collectionId .'"']),
|
Query::equal('type', [Database::VAR_RELATIONSHIP]),
|
||||||
Query::limit(PHP_INT_MAX)
|
Query::notEqual('collectionInternalId', $collectionInternalId),
|
||||||
]);
|
Query::contains('options', ['"relatedCollection":"'. $collectionId .'"']),
|
||||||
|
],
|
||||||
foreach ($attributes as $attribute) {
|
$dbForProject,
|
||||||
$dbForProject->deleteDocument('attributes', $attribute->getId());
|
function ($attribute) use ($dbForProject, $databaseInternalId) {
|
||||||
Console::success('Deleted document "' . $attribute->getId() . '" related collection successfully');
|
$dbForProject->deleteDocument('attributes', $attribute->getId());
|
||||||
$dbForProject->purgeCachedDocument('database_' . $databaseInternalId, $attribute->getAttribute('collectionId'));
|
Console::success('Deleted document "' . $attribute->getId() . '" related collection successfully');
|
||||||
$dbForProject->purgeCachedCollection('database_' . $databaseInternalId . '_collection_' . $attribute->getAttribute('collectionInternalId'));
|
$dbForProject->purgeCachedDocument('database_' . $databaseInternalId, $attribute->getAttribute('collectionId'));
|
||||||
}
|
$dbForProject->purgeCachedCollection('database_' . $databaseInternalId . '_collection_' . $attribute->getAttribute('collectionInternalId'));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
$dbForProject->deleteCollection('database_' . $databaseInternalId . '_collection_' . $collection->getInternalId());
|
$dbForProject->deleteCollection('database_' . $databaseInternalId . '_collection_' . $collection->getInternalId());
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue