Cloud Datastore Client - Class EntityMapper (1.19.0)

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

Utility methods for mapping between datastore andGoogle\Cloud\Datastore\Entity.

Methods

__construct

Create an Entity Mapper

Parameters
NameDescription
projectIdstring

The datastore project ID

encodebool

Whether to encode blobs as base64.

returnInt64AsObjectbool

If true, 64 bit integers will bereturned as a {@see \Google\Cloud\Datastore\Google\Cloud\Core\Int64} object for 32 bitplatform compatibility.

responseToEntityProperties

Convert an entity response to properties, excludes and meanings.

Parameters
NameDescription
entityDataarray

The incoming entity

classNamestring

The name of a class to use as the entity. Mustimplement {@see \Google\Cloud\Datastore\Google\Cloud\Datastore\EntityInterface}.

Returns
TypeDescription
array

objectToRequest

Translate an Entity to a datastore representation.

Parameter
NameDescription
entityGoogle\Cloud\Datastore\EntityInterface

The input entity.

Returns
TypeDescription
arrayA Datastore [Entity](https://cloud.google.com/datastore/reference/rest/v1/Entity)

convertValue

Convert a Datastore value object to a simple value

Parameters
NameDescription
typestring

The value type

valuemixed

The value

classNamestring

[optional] The object type to decode to, if type is entityValue.

Returns
TypeDescription
mixed

valueObject

Format values for the API

Parameters
NameDescription
valuemixed
excludebool

[optional] If true, value will be excluded from datastore indexes.

meaningint

[optional] The Meaning value. Maintained only for backwards compatibility.

Returns
TypeDescription
array

objectProperty

Convert different object types to API values

Parameter
NameDescription
valuemixed

The value object

Returns
TypeDescription
array

Constants

DATE_FORMAT

Value: 'Y-m-d\\TH:i:s.uP'

DATE_FORMAT_NO_MS

Value: 'Y-m-d\\TH:i:sP'

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-01-24 UTC.