php - Save property type int google datastore
How can I define the property type, when I save a record into Google Datastore with PHP?
version should be type: Integer
color should be type: String
description should be type: Text (I want to save long text there)
created should be type: Date and time
and cardatas should be type Array or Text,
what is the best here for JSON datas?: Array or Text
$datastore = new DatastoreClient();
$key = 'protCarDatas';
$time = date(DATE_RFC3339);
$savedata = $datastore->entity(
$key,
[
'version' => $version,
'color' => $color,
'description' => $desc,
'created' => $time,
'cardatas' => $fullCardDataJsonString
],
['excludeFromIndexes' => ['cardatas']]
);
$datastore->insert($savedata);
Thanks for help!
Answer
Solution:
The types that Datastore supports are the following (from the Documentation):
So I would cast the variables to: