CollectionManagementTrait
Collection-management surface of the {@see \oihana\arango\db\ArangoDB} façade. Methods preserve their legacy signatures; their internals were switched in Lot 6.1 from the legacy `client/CollectionHandler` to the new `clients/Collection` (and `clients/Database`).
Every method returning bool maps server-side exceptions to false
silently; collectionRename() lets the
oihana\arango\clients\exceptions\ArangoException propagate directly.
The index surface lives in IndexManagementTrait, which composes
this trait.
Table of Contents
Properties
Methods
- collectionCreate() : bool
- Creates a new collection if it does not already exist.
- collectionDiff() : DiffReport
- Compares a declared collection with the server state and reports the difference — the collection half of the `doctor` diagnosis.
- collectionDrop() : bool
- Drops a collection if it exists.
- collectionExists() : bool
- Checks if a collection exists.
- collectionRename() : bool
- Renames a collection if it exists.
- collectionTruncate() : bool
- Truncates a collection if it exists.
- resolveCollectionName() : string
- Resolves a collection reference (string name or {@see Collection} client handle) to its string name.
Properties
$database
protected
Database
$database
Database scope shared with the parent façade.
Methods
collectionCreate()
Creates a new collection if it does not already exist.
public
collectionCreate(string $name[, array<string, mixed> $options = [] ]) : bool
Parameters
- $name : string
-
The name of the new collection.
- $options : array<string, mixed> = []
-
Forwarded to
POST /_api/collection(type,waitForSync,keyOptions,numberOfShards,replicationFactor,writeConcern,shardKeys,shardingStrategy,schema, …).
Return values
bool —TRUE when the collection has been created, FALSE when it already existed or the request failed.
collectionDiff()
Compares a declared collection with the server state and reports the difference — the collection half of the `doctor` diagnosis.
public
collectionDiff(string $name[, int|null $type = null ]) : DiffReport
The check is existence first (DiffStatus::MISSING when the
collection is absent), then — when $type is given — the collection
type (2 document / 3 edge): a mismatch is reported as
DiffStatus::DRIFTED (a collection type cannot be changed, the
repair is manual by design).
Parameters
- $name : string
-
The name of the collection.
- $type : int|null = null
-
The declared collection type (
2document,3edge), or null to skip the type check.
Return values
DiffReport —The typed report (DiffKind::COLLECTION).
collectionDrop()
Drops a collection if it exists.
public
collectionDrop(string $name) : bool
Parameters
- $name : string
-
The name of the collection.
Return values
bool —TRUE when the collection has been dropped, FALSE otherwise.
collectionExists()
Checks if a collection exists.
public
collectionExists(string $name) : bool
Parameters
- $name : string
-
The name of the collection.
Return values
boolcollectionRename()
Renames a collection if it exists.
public
collectionRename(string $oldName, string $name) : bool
Parameters
- $oldName : string
-
The current name of the collection.
- $name : string
-
The new name of the collection.
Tags
Return values
bool —TRUE when the collection has been renamed.
collectionTruncate()
Truncates a collection if it exists.
public
collectionTruncate(string $name) : bool
Parameters
- $name : string
-
The name of the collection.
Return values
bool —TRUE when the collection has been truncated.
resolveCollectionName()
Resolves a collection reference (string name or {@see Collection} client handle) to its string name.
protected
resolveCollectionName(string|Collection $collection) : string
Parameters
- $collection : string|Collection