Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/schema-collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ Delete a collection
```
$arangoClient->schema()->deleteCollection('users');
```

### deleteAllCollections(): bool
This method deletes all non-system collections available on the current database.

Expand Down
7 changes: 7 additions & 0 deletions docs/schema-views.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,10 @@ $arangoClient->schema()->updateView('pages', [
$arangoClient->schema()->deleteView('testViewBasics');
```

### deleteAllViews(): bool
This method deletes all views available on the current database.

```
$arangoClient->schema()->deleteAllViews();
```

14 changes: 14 additions & 0 deletions src/Schema/ManagesViews.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,20 @@ public function deleteView(string $name): bool
return (bool) $this->arangoClient->request('delete', $uri);
}

/**
* @throws ArangoException
*/
public function deleteAllViews(): bool
{
$views = $this->getViews();

foreach ($views as $view) {
$this->deleteView($view->name);
}

return true;
}

/**
* @see https://www.arangodb.com/docs/stable/http/views-arangosearch.html#list-all-views
*
Expand Down
22 changes: 22 additions & 0 deletions tests/SchemaManagerViewsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,25 @@
$deleted = $this->schemaManager->deleteView($view['name']);
expect($deleted)->toBeTrue();
});

test('deleteAllViews', function () {
$view1 = [
'name' => 'view1',
];
$view2 = [
'name' => 'view2',
];
$this->schemaManager->createView($view1);
$this->schemaManager->createView($view2);


$createdViews = $this->schemaManager->getViews();

$result = $this->schemaManager->deleteAllViews();

$finalViews = $this->schemaManager->getViews();

expect($result)->toBeTrue();
expect(count($createdViews))->toBe(3);
expect(count($finalViews))->toBe(0);
});