Menu

## Collection
in package
implements JsonSerializable

Collection.php : 33

Represents an ArangoDB collection

##### Tags

author

  Lucas S. Vieira

### Table of Contents

#### Interfaces

JsonSerializable

#### Methods

__construct() : mixed
  Collection constructor.
__get() : mixed|null
  Get some attribute
__set() : mixed
  Set a attribute
__toString() : string
  Return an string representation of document
addIndex() : bool
  Create a 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 a index of collection
findByKey() : Document|false
  Find a document by it's 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
load() : bool
  Loads the collection on server
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

### Methods

#### __construct()

Collection.php : 156

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

throws
  DatabaseException|GuzzleException|MissingParameterException|InvalidParameterException

#### __get()

Collection.php : 187

Get some attribute

`public __get(string $name) : mixed|null`

##### Parameters

$name : string

##### Return values

mixed|null

#### __set()

Collection.php : 203

Set a attribute

`public __set(string $name, mixed $value) : mixed`

##### Parameters

$name : string
$value : mixed

##### Tags

throws
  Exception

#### __toString()

Collection.php : 176

Return an string representation of document

`public __toString() : string`

##### Return values

string

#### addIndex()

Collection.php : 449

Create a index for collection

`public addIndex(IndexInterface $index) : bool`

##### Parameters

$index : IndexInterface

##### Tags

throws
  DatabaseException|GuzzleException

##### Return values

bool

#### all()

Collection.php : 220

Returns a cursor for access all documents on this Collection

`public all() : CursorInterface|bool`

##### Tags

throws
  GuzzleException|InvalidParameterException|CursorException

##### Return values

CursorInterface|bool —

Cursor if collection exists on database. False otherwise.

#### count()

Collection.php : 637

Return the number of documents in a collection.

`public count() : int`

##### Tags

throws
  DatabaseException|GuzzleException

##### Return values

int —

Total count of documents on collection.

#### drop()

Collection.php : 537

Drops the collection on database

`public drop() : bool`

##### Tags

throws
  DatabaseException|GuzzleException

##### Return values

bool

#### dropIndex()

Collection.php : 476

Drops a index of collection

`public dropIndex(IndexInterface $index) : bool`

##### Parameters

$index : IndexInterface

##### Tags

throws
  DatabaseException|GuzzleException

##### Return values

bool

#### findByKey()

Collection.php : 607

Find a document by it's 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

throws
  DatabaseException|GuzzleException|InvalidParameterException|MissingParameterException

##### Return values

Document|false

#### getAttributes()

Collection.php : 234

Return the collection attributes on array

`public getAttributes() : array<string|int, mixed>`

##### Return values

array<string|int, mixed>

#### getChecksum()

Collection.php : 372

Return the checksum of collection metadata

`public getChecksum() : string`

##### Tags

throws
  DatabaseException|GuzzleException

##### Return values

string

#### getDatabase()

Collection.php : 258

Returns the database where collection belongs

`public getDatabase() : Database`

##### Return values

Database

#### getGloballyUniqueId()

Collection.php : 288

Return the globally Unique ID of collection

`public getGloballyUniqueId() : string`

##### Return values

string

#### getId()

Collection.php : 278

Return the ID of collection

`public getId() : string|null`

##### Return values

string|null —

String if collection exists on database. Null if not.

#### getIndexes()

Collection.php : 396

Return all indexes of collection

`public getIndexes() : ArrayList`

##### Tags

throws
  DatabaseException|GuzzleException|InvalidParameterException|IndexException|MissingParameterException

##### Return values

ArrayList

#### getName()

Collection.php : 268

Return the name of collection

`public getName() : string`

##### Return values

string

#### getRevision()

Collection.php : 424

Return the revision of collection

`public getRevision() : string`

##### Tags

throws
  DatabaseException|GuzzleException

##### Return values

string

#### getStatus()

Collection.php : 298

Return the status of collection

`public getStatus() : int`

##### Return values

int —

A integer between 0 and 6

#### getStatusDescription()

Collection.php : 308

Return a string description of status

`public getStatusDescription() : string`

##### Return values

string

#### getType()

Collection.php : 318

Return the collection type

`public getType() : string`

##### Return values

string

#### isGraph()

Collection.php : 348

Return if the collection is a graph collection

`public isGraph() : bool`

##### Return values

bool

#### isNew()

Collection.php : 338

Returns true if is a new object

`public isNew() : bool`

##### Return values

bool

#### isSystem()

Collection.php : 328

Checks if the collection is a system collection

`public isSystem() : bool`

##### Return values

bool —

True if is a system collection. False otherwise.

#### jsonSerialize()

Collection.php : 695
`public jsonSerialize() : mixed`

##### Tags

see
  JsonSerializable::jsonSerialize()

#### load()

Collection.php : 583

Loads the collection on server

`public load([bool $count = true ]) : bool`

##### Parameters

$count : bool = true

##### Tags

throws
  DatabaseException|GuzzleException

##### Return values

bool

#### recalculateCount()

Collection.php : 657

Recalculates the document count of a collection, if it ever becomes inconsistent.

`public recalculateCount() : bool`

##### Tags

throws
  DatabaseException|GuzzleException

##### Return values

bool

#### rename()

Collection.php : 678

Renames the collection

`public rename(string $newName) : bool`

##### Parameters

$newName : string

  The new name of collection.

##### Tags

throws
  DatabaseException|GuzzleException

##### Return values

bool

#### save()

Collection.php : 509

Saves or update the collection.

`public save() : bool`

Except for 'waitForSync', 'journalSize' and 'name', a collection can not be modified after creation. For change 'name', the method 'rename' must be used.

##### Tags

throws
  DatabaseException|GuzzleException

##### Return values

bool

#### setAttributes()

Collection.php : 244

Set collection attributes

`public setAttributes(array<string|int, mixed> $data) : void`

##### Parameters

$data : array<string|int, mixed>

#### toArray()

Collection.php : 358

Return an array representation of collection

`public toArray() : array<string|int, mixed>`

##### Return values

array<string|int, mixed>

#### truncate()

Collection.php : 563

Truncate the collection

`public truncate() : bool`

##### Tags

throws
  DatabaseException|GuzzleException

##### Return values

bool

## Search results