Value object representing a single collection-based document


package ArangoDBClient
since 0.2

 Methods

Clone a document

__clone() : void

Returns the clone

magic

Constructs an empty document

__construct(array $options = null

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

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

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

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

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) 

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
Static

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

Parameters

$attributes

array
  • attributes array

$_hiddenAttributes

array

Returns

array- attributes array

Get a document attribute

get(string $key) : mixed

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

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

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

Returns

mixed- associative array of all document attributes/values

Get the changed flag

getChanged() : boolean

Returns

boolean- true if document was changed, false otherwise

Get the collection id (if already known)

getCollectionId() : mixed

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

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

getHandle() : string

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

Returns

array$attributes - array of attributes

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

getId() : mixed

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

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

Returns

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

Get the isNew flag

getIsNew() : boolean

Returns

boolean$isNew - flags if new or existing doc

Get the document key (if already known).

getKey() : mixed

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

Returns

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

isIgnoreHiddenAttributes()

isIgnoreHiddenAttributes() : boolean

Returns

boolean

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

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

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.

Parameters

$key

string
  • attribute name

$value

mixed
  • value for attribute

Exceptions

\ArangoDBClient\ClientException

Set the changed flag

setChanged(boolean $value) : boolean

Parameters

$value

boolean
  • change flag

Returns

boolean

Set the hidden attributes $cursor

setHiddenAttributes(array $attributes) : void

Parameters

$attributes

array
  • array of attributes

setIgnoreHiddenAttributes()

setIgnoreHiddenAttributes(boolean $ignoreHiddenAttributes) 

Parameters

$ignoreHiddenAttributes

boolean

Set the internal document id

setInternalId(string $id) : void

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

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

Parameters

$isNew

boolean
  • flags if new or existing doc

Set the document revision

setRevision(mixed $rev) : void

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

Returns the document as JSON-encoded string

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

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

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
 

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 document attributes (names/values)

$_values : array

Default

array()

 Constants

 

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' 
 

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'