Value object representing a single collection-based edge document


package ArangoDBClient
since 1.0
inherited_from \ArangoDBClient\Document

 Methods

Clone a document

__clone() : void
Inherited

Returns the clone

magic

Constructs an empty document

__construct(array $options = null
Inherited

Parameters

$options

array
  • optional, initial $options for document

    Options are :

  • '_hiddenAttributes' - Set an array of hidden attributes for created documents.
  • '_ignoreHiddenAttributes' - true to show hidden attributes. Defaults to false

Get a document attribute, magic method

__get(string $key) : mixed
Inherited

This function is mapped to get() internally.

magic

Parameters

$key

string
  • name of attribute

Returns

mixed- value of attribute, NULL if attribute is not set

Is triggered by calling isset() or empty() on inaccessible properties.

__isset(string $key) : boolean
Inherited

Parameters

$key

string
  • name of attribute

Returns

booleanreturns true or false (set or not set)

Set a document attribute, magic method

__set(string $key, mixed $value) : void
Inherited

This is a magic method that allows the object to be used without declaring all document attributes first. This function is mapped to set() internally.

magic

Parameters

$key

string
  • attribute name

$value

mixed
  • value for attribute

Exceptions

\ArangoDBClient\ClientException

Get a string representation of the document.

__toString() : string
Inherited

It will not output hidden attributes.

Returns the document as JSON-encoded string

magic

Returns

string- JSON-encoded document

Magic method to unset an attribute.

__unset($key) 
Inherited

Caution!!! This works only on the first array level. The preferred method to unset attributes in the database, is to set those to null and do an update() with the option: 'keepNull' => false.

magic

Parameters

$key

Factory method to construct a new document using the values passed to populate it

createFromArray(array $values, array $options = array()) : \ArangoDBClient\Document | \ArangoDBClient\Edge | \ArangoDBClient\Graph
InheritedStatic

Parameters

$values

array
  • initial values for document

$options

array
  • optional, initial options for document

Exceptions

\ArangoDBClient\ClientException

Returns

\ArangoDBClient\Document\ArangoDBClient\Edge\ArangoDBClient\Graph

Returns the attributes with the hidden ones removed

filterHiddenAttributes(array $attributes, array $_hiddenAttributes = array()) : array
Inherited

Parameters

$attributes

array
  • attributes array

$_hiddenAttributes

array

Returns

array- attributes array

Get a document attribute

get(string $key) : mixed
Inherited

Parameters

$key

string
  • name of attribute

Returns

mixed- value of attribute, NULL if attribute is not set

Get all document attributes

getAll(mixed $options = array()) : array
Inherited

Parameters

$options

mixed
  • optional, array of options for the getAll function, or the boolean value for $includeInternals

    Options are :

  • '_includeInternals' - true to include the internal attributes. Defaults to false
  • '_ignoreHiddenAttributes' - true to show hidden attributes. Defaults to false

Returns

array- array of all document attributes/values

Get all document attributes, and return an empty object if the documentapped into a DocumentWrapper class

getAllAsObject(mixed $options = array()) : mixed
Inherited

Parameters

$options

mixed
  • optional, array of options for the getAll function, or the boolean value for $includeInternals

    Options are :

  • '_includeInternals' - true to include the internal attributes. Defaults to false
  • '_ignoreHiddenAttributes' - true to show hidden attributes. Defaults to false

Returns

mixed- associative array of all document attributes/values, or an empty StdClass if the document does not have any

Get all document attributes for insertion/update

getAllForInsertUpdate() : mixed
inherited_from \ArangoDBClient\Document::getAllForInsertUpdate()

Returns

mixed- associative array of all document attributes/values

Get all document attributes for insertion/update

getAllForInsertUpdate() : mixed
Inherited

Returns

mixed- associative array of all document attributes/values

Get the changed flag

getChanged() : boolean
Inherited

Returns

boolean- true if document was changed, false otherwise

Get the collection id (if already known)

getCollectionId() : mixed
Inherited

Collection ids are generated on the server only. Collection ids are numeric but might be bigger than PHP_INT_MAX. To reliably store a collection id elsewhere, a PHP string should be used

Returns

mixed- collection id, might be NULL if document does not yet have an id

Get the 'from' vertex document-handler (if already known)

getFrom() : mixed

Returns

mixed- document-handler

Convenience function to get the document handle (if already known) - is an alias to getInternalId()

getHandle() : string
Inherited

Document handles are generated on the server only. Document handles consist of collection id and document id, in the format collectionId/documentId

Returns

string- internal document id, might be NULL if document does not yet have an id

Get the hidden attributes

getHiddenAttributes() : array
Inherited

Returns

array$attributes - array of attributes

Get the document id (or document handle) if already known.

getId() : mixed
Inherited

It is a string and consists of the collection's name and the document key (_key attribute) separated by /. Example: (collectionname/documentId)

The document handle is stored in a document's _id attribute.

Returns

mixed- document id, might be NULL if document does not yet have an id.

Get the internal document id (if already known)

getInternalId() : string
Inherited

Document ids are generated on the server only. Document ids consist of collection id and document id, in the format collectionId/documentId

Returns

string- internal document id, might be NULL if document does not yet have an id

Get the internal document key (if already known)

getInternalKey() : string
Inherited

Returns

string- internal document key, might be NULL if document does not yet have a key

Get the isNew flag

getIsNew() : boolean
Inherited

Returns

boolean$isNew - flags if new or existing doc

Get the document key (if already known).

getKey() : mixed
Inherited

Alias function for getInternalKey()

Returns

mixed- document key, might be NULL if document does not yet have a key

Get the document revision (if already known)

getRevision() : mixed
Inherited

Returns

mixed- revision id, might be NULL if document does not yet have an id

Get the 'to' vertex document-handler (if already known)

getTo() : mixed

Returns

mixed- document-handler

isIgnoreHiddenAttributes()

isIgnoreHiddenAttributes() : boolean
Inherited

Returns

boolean

Get all document attributes Alias function for getAll() - it's necessary for implementing JsonSerializable interface

jsonSerialize(mixed $options = array()) : array
Inherited

Parameters

$options

mixed
  • optional, array of options for the getAll function, or the boolean value for $includeInternals

    Options are :

  • '_includeInternals' - true to include the internal attributes. Defaults to false
  • '_ignoreHiddenAttributes' - true to show hidden attributes. Defaults to false

Returns

array- array of all document attributes/values

Set a document attribute

set(string $key, mixed $value) : void

The key (attribute name) must be a string.

This will validate the value of the attribute and might throw an exception if the value is invalid.

inherited_from \ArangoDBClient\Document::set()

Parameters

$key

string
  • attribute name

$value

mixed
  • value for attribute

Exceptions

\ArangoDBClient\ClientException

Set a document attribute

set(string $key, mixed $value) : void
Inherited

The key (attribute name) must be a string. This will validate the value of the attribute and might throw an exception if the value is invalid.

Parameters

$key

string
  • attribute name

$value

mixed
  • value for attribute

Exceptions

\ArangoDBClient\ClientException

Set the changed flag

setChanged(boolean $value) : boolean
Inherited

Parameters

$value

boolean
  • change flag

Returns

boolean

Set the 'from' vertex document-handler

setFrom(mixed $from) : \ArangoDBClient\Edge

Parameters

$from

mixed
  • from vertex

Returns

\ArangoDBClient\Edge- edge object

Set the hidden attributes $cursor

setHiddenAttributes(array $attributes) : void
Inherited

Parameters

$attributes

array
  • array of attributes

setIgnoreHiddenAttributes()

setIgnoreHiddenAttributes(boolean $ignoreHiddenAttributes) 
Inherited

Parameters

$ignoreHiddenAttributes

boolean

Set the internal document id

setInternalId(string $id) : void
Inherited

This will throw if the id of an existing document gets updated to some other id

Parameters

$id

string
  • internal document id

Exceptions

\ArangoDBClient\ClientException

Set the internal document key

setInternalKey(string $key) : void
Inherited

This will throw if the key of an existing document gets updated to some other key

Parameters

$key

string
  • internal document key

Exceptions

\ArangoDBClient\ClientException

Set the isNew flag

setIsNew(boolean $isNew) : void
Inherited

Parameters

$isNew

boolean
  • flags if new or existing doc

Set the document revision

setRevision(mixed $rev) : void
Inherited

Revision ids are generated on the server only.

Document ids are strings, even if they look "numeric" To reliably store a document id elsewhere, a PHP string must be used

Parameters

$rev

mixed
  • revision id

Set the 'to' vertex document-handler

setTo(mixed $to) : \ArangoDBClient\Edge

Parameters

$to

mixed
  • to vertex

Returns

\ArangoDBClient\Edge- edge object

Returns the document as JSON-encoded string

toJson(array $options = array()) : string
Inherited

Parameters

$options

array
  • optional, array of options that will be passed to the getAll function

    Options are :

  • '_includeInternals' - true to include the internal attributes. Defaults to false
  • '_ignoreHiddenAttributes' - true to show hidden attributes. Defaults to false

Returns

string- JSON-encoded document

Returns the document as a serialized string

toSerialized(array $options = array()) : string
Inherited

Parameters

$options

array
  • optional, array of options that will be passed to the getAll function

    Options are :

  • '_includeInternals' - true to include the internal attributes. Defaults to false
  • '_ignoreHiddenAttributes' - true to show hidden attributes. Defaults to false

Returns

string- PHP serialized document

 Properties

 

Flag to indicate whether document was changed locally

$_changed : boolean

Default

false
 

Flag to indicate whether validation of document values should be performed This can be turned on, but has a performance penalty

$_doValidate : boolean

Default

false
 

The edge's from (might be NULL for new documents)

$_from : mixed

Default

 

An array, that defines which attributes should be treated as hidden.

$_hiddenAttributes : array

Default

array()
 

The document id (might be NULL for new documents)

$_id : string

Default

 

Flag to indicate whether hidden attributes should be ignored or included in returned data-sets

$_ignoreHiddenAttributes : boolean

Default

false
 

Flag to indicate whether document is a new document (never been saved to the server)

$_isNew : boolean

Default

true
 

The document key (might be NULL for new documents)

$_key : string

Default

 

The document revision (might be NULL for new documents)

$_rev : mixed

Default

 

The edge's to (might be NULL for new documents)

$_to : mixed

Default

 

The document attributes (names/values)

$_values : array

Default

array()

 Constants

 

Document _from index

ENTRY_FROM = '_from' 
 

hidden attribute index

ENTRY_HIDDENATTRIBUTES = '_hiddenAttributes' 
 

Document id index

ENTRY_ID = '_id' 
 

hidden attribute index

ENTRY_IGNOREHIDDENATTRIBUTES = '_ignoreHiddenAttributes' 
 

isNew id index

ENTRY_ISNEW = '_isNew' 
 

Document key index

ENTRY_KEY = '_key' 
 

Revision id index

ENTRY_REV = '_rev' 
 

Revision _to index

ENTRY_TO = '_to' 
 

regular expression used for key validation

KEY_REGEX_PART = '[a-zA-Z0-9_:.@\\-()+,=;$!*\'%]{1,254}' 
 

keepNull option index

OPTION_KEEPNULL = 'keepNull' 
 

policy option index

OPTION_POLICY = 'policy' 
 

waitForSync option index

OPTION_WAIT_FOR_SYNC = 'waitForSync'