Cloud Datastore Client - Class EntityInterface (2.0.6)

Reference documentation and code samples for the Cloud Datastore Client class EntityInterface.

Defines an interface for Datastore Entities.

This interface is fulfilled by EntityTrait, and it is recommended that classes implementing EntityInterface make use of that trait to ensure proper configuration.

Namespace

Google \ Cloud \ Datastore

Methods

get

Return all entity data as an array.

Returns
Type Description
array

set

Set the entity body.

Parameter
Name Description
entity array

The new entity body.

Returns
Type Description
void

key

Return the Datastore key, or null if no key is present.

Returns
Type Description
Key|null

cursor

Fetch the cursor

This is only set when the entity was obtained from a query result. It can be used to manually paginate results.

Returns
Type Description
string|null

baseVersion

Fetch the baseVersion

This is only set when the entity was obtained from a query result. It is used for concurrency control internally.

Returns
Type Description
string|null

populatedByService

Indicate whether the entity was created as the result of an API call.

Returns
Type Description
bool

setExcludeFromIndexes

A list of entity properties to exclude from datastore indexes.

Parameter
Name Description
properties array

A list of properties to exclude from indexes.

Returns
Type Description
void

excludedProperties

Return a list of properties excluded from datastore indexes.

Returns
Type Description
array

meanings

Return a list of meaning values.

Returns
Type Description
array

static::build

Create an instance of the entity class.

This factory method allows the implementor to define the means by which the key, entity data and entity options are managed within the entity implementation. This method is called by the Google Cloud PHP client to create entities.

Parameters
Name Description
key Key|null

[optional] The Entity's Key, defining its unique identifier. Defaults to null.

entity array

[optional] The entity body. Defaults to [].

options array

Configuration Options

↳ cursor string

Set only when the entity is obtained by a query result. If set, the entity cursor can be retrieved from EntityInterface::cursor().

↳ baseVersion string

Set only when the entity is obtained by a query result. If set, the entity cursor can be retrieved from EntityInterface::baseVersion().

↳ excludeFromIndexes array

A list of entity keys to exclude from datastore indexes.

↳ meanings array

A list of meaning values for entity properties.

↳ populatedByService bool

Indicates whether the entity was created as the result of a service request.

static::mappings

Defines embedded entity mappings.

Embedded entities are converted to instances of Entity, or to associative arrays by default. By providing mappings, you can define the types to use in your application.

Types must implement EntityInterface.

Returns
Type Description
array An associative array, where the key is the property name, and the value is the fully-qualified name of a PHP class implementing {@see \Google\Cloud\Datastore\EntityInterface}.

Constants

EXCLUDE_FROM_INDEXES

Value: '___GOOGLECLOUDPHP___EXCLUDEFROMINDEXES___'