Collection
in package
implements
JsonSerializable
uses
IndexableTrait
Represents an ArangoDB collection
Tags
Table of Contents
Interfaces
- JsonSerializable
Properties
- $attributes : array<string|int, mixed>
- Attributes of collection
- $connection : Connection
- Connection object
- $database : Database
- Database object
- $deletedStatus : int
- Deleted status of collection
- $descriptorAttributes : array<string|int, mixed>
- Fields to be set directly
- $isNew : bool
- If the collection is a new one or a representation of an existing collection on server
- $loadedStatus : int
- Loaded status of collection
- $loadingStatus : int
- Loading status of collection
- $statusStrings : array<string|int, mixed>
- Status descriptions
- $typeStrings : array<string|int, mixed>
- Type descriptions
- $unknownStatus : int
- Unknown status of collection
- $unloadedStatus : int
- Unloaded status of collection
- $unloadingStatus : int
- Unloading status of collection
- $defaults : array<string|int, mixed>
- Default values when creating collections
Methods
- __construct() : mixed
- Collection constructor.
- __get() : mixed|null
- Get some attribute
- __set() : mixed
- Set an attribute
- __toString() : string
- Return a string representation of document
- addIndex() : bool
- Create an index for collection
- all() : CursorInterface|bool
- Returns a cursor for access all documents on this Collection
- count() : int
- Return the number of documents in a collection.
- drop() : bool
- Drops the collection on database
- dropIndex() : bool
- Drops an index of collection
- findByKey() : Document|false
- Find a document by its key
- getAttributes() : array<string|int, mixed>
- Return the collection attributes on array
- getChecksum() : string
- Return the checksum of collection metadata
- getDatabase() : Database
- Returns the database where collection belongs
- getGloballyUniqueId() : string
- Return the globally Unique ID of collection
- getId() : string|null
- Return the ID of collection
- getIndexes() : ArrayList
- Return all indexes of collection
- getName() : string
- Return the name of collection
- getRevision() : string
- Return the revision of collection
- getStatus() : int
- Return the status of collection
- getStatusDescription() : string
- Return a string description of status
- getType() : string
- Return the collection type
- isGraph() : bool
- Return if the collection is a graph collection
- isNew() : bool
- Returns true if is a new object
- isSystem() : bool
- Checks if the collection is a system collection
- jsonSerialize() : mixed
- recalculateCount() : bool
- Recalculates the document count of a collection, if it ever becomes inconsistent.
- rename() : bool
- Renames the collection
- save() : bool
- Saves or update the collection.
- setAttributes() : void
- Set collection attributes
- toArray() : array<string|int, mixed>
- Return an array representation of collection
- truncate() : bool
- Truncate the collection
- getCreateParameters() : array<string|int, mixed>
- Return only fields to be sent on a POST request
- getUpdateParameters() : array<string|int, mixed>
- Return only fields to update this collection.
- update() : bool
- Update collection.
Properties
$attributes
Attributes of collection
protected
array<string|int, mixed>
$attributes
$connection
Connection object
protected
Connection
$connection
$database
Database object
protected
Database
$database
$deletedStatus
Deleted status of collection
protected
static int
$deletedStatus
= 5
$descriptorAttributes
Fields to be set directly
protected
array<string|int, mixed>
$descriptorAttributes
= ['id' => null, 'objectId' => null, 'name' => '', 'type' => 2, 'status' => 0, 'cacheEnabled' => false, 'isSystem' => false, 'globallyUniqueId' => '', 'revision' => 0, 'count' => 0, 'checksum' => '']
$isNew
If the collection is a new one or a representation of an existing collection on server
protected
bool
$isNew
$loadedStatus
Loaded status of collection
protected
static int
$loadedStatus
= 3
$loadingStatus
Loading status of collection
protected
static int
$loadingStatus
= 6
$statusStrings
Status descriptions
protected
array<string|int, mixed>
$statusStrings
= [0 => 'unknown', 1 => 'unknown', 2 => 'unloaded', 3 => 'loaded', 4 => 'unloading', 5 => 'deleted', 6 => 'loading']
$typeStrings
Type descriptions
protected
array<string|int, mixed>
$typeStrings
= [2 => 'document', 3 => 'graph']
$unknownStatus
Unknown status of collection
protected
static int
$unknownStatus
= 1
$unloadedStatus
Unloaded status of collection
protected
static int
$unloadedStatus
= 2
$unloadingStatus
Unloading status of collection
protected
static int
$unloadingStatus
= 4
$defaults
Default values when creating collections
private
array<string|int, mixed>
$defaults
= ['replicationFactor' => 1, 'waitForSync' => false, 'shardingStrategy' => 'community-compat', 'shardKeys' => ["_key"], 'numberOfShards' => 1, 'isSystem' => false, 'type' => 2, 'keyOptions' => ['allowUserKeys' => true, 'type' => \ArangoDB\Collection\KeyType::TRADITIONAL]]
Methods
__construct()
Collection constructor.
public
__construct(string $name, Database $database[, array<string|int, mixed> $attributes = [] ]) : mixed
Parameters
- $name : string
- $database : Database
- $attributes : array<string|int, mixed> = []
Tags
__get()
Get some attribute
public
__get(string $name) : mixed|null
Parameters
- $name : string
Return values
mixed|null__set()
Set an attribute
public
__set(string $name, mixed $value) : mixed
Parameters
- $name : string
- $value : mixed
Tags
__toString()
Return a string representation of document
public
__toString() : string
Return values
stringaddIndex()
Create an index for collection
public
addIndex(IndexInterface $index) : bool
Parameters
- $index : IndexInterface
Tags
Return values
boolall()
Returns a cursor for access all documents on this Collection
public
all() : CursorInterface|bool
Tags
Return values
CursorInterface|bool —Cursor if collection exists on database. False otherwise.
count()
Return the number of documents in a collection.
public
count() : int
Tags
Return values
int —Total count of documents on collection.
drop()
Drops the collection on database
public
drop() : bool
Tags
Return values
booldropIndex()
Drops an index of collection
public
dropIndex(IndexInterface $index) : bool
Parameters
- $index : IndexInterface
Tags
Return values
boolfindByKey()
Find a document by its key
public
findByKey(string $key[, bool $isVertex = false ]) : Document|false
Parameters
- $key : string
-
Document key
- $isVertex : bool = false
-
If the collection is a vertex in a graph, passing true will return document as Vertex object.
Tags
Return values
Document|falsegetAttributes()
Return the collection attributes on array
public
getAttributes() : array<string|int, mixed>
Return values
array<string|int, mixed>getChecksum()
Return the checksum of collection metadata
public
getChecksum() : string
Tags
Return values
stringgetDatabase()
Returns the database where collection belongs
public
getDatabase() : Database
Return values
DatabasegetGloballyUniqueId()
Return the globally Unique ID of collection
public
getGloballyUniqueId() : string
Return values
stringgetId()
Return the ID of collection
public
getId() : string|null
Return values
string|null —String if collection exists on database. Null if not.
getIndexes()
Return all indexes of collection
public
getIndexes() : ArrayList
Tags
Return values
ArrayListgetName()
Return the name of collection
public
getName() : string
Return values
stringgetRevision()
Return the revision of collection
public
getRevision() : string
Tags
Return values
stringgetStatus()
Return the status of collection
public
getStatus() : int
Return values
int —An integer between 0 and 6
getStatusDescription()
Return a string description of status
public
getStatusDescription() : string
Return values
stringgetType()
Return the collection type
public
getType() : string
Return values
stringisGraph()
Return if the collection is a graph collection
public
isGraph() : bool
Return values
boolisNew()
Returns true if is a new object
public
isNew() : bool
Return values
boolisSystem()
Checks if the collection is a system collection
public
isSystem() : bool
Return values
bool —True if is a system collection. False otherwise.
jsonSerialize()
public
jsonSerialize() : mixed
Tags
recalculateCount()
Recalculates the document count of a collection, if it ever becomes inconsistent.
public
recalculateCount() : bool
Tags
Return values
boolrename()
Renames the collection
public
rename(string $newName) : bool
Parameters
- $newName : string
-
The new name of collection.
Tags
Return values
boolsave()
Saves or update the collection.
public
save() : bool
Except for 'waitForSync' and 'name', a collection can not be modified after creation. For change 'name', the method 'rename' must be used.
Tags
Return values
boolsetAttributes()
Set collection attributes
public
setAttributes(array<string|int, mixed> $data) : void
Parameters
- $data : array<string|int, mixed>
toArray()
Return an array representation of collection
public
toArray() : array<string|int, mixed>
Return values
array<string|int, mixed>truncate()
Truncate the collection
public
truncate() : bool
Tags
Return values
boolgetCreateParameters()
Return only fields to be sent on a POST request
protected
getCreateParameters() : array<string|int, mixed>
Return values
array<string|int, mixed>getUpdateParameters()
Return only fields to update this collection.
protected
getUpdateParameters() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>update()
Update collection.
private
update() : bool