首页 > 解决方案 > 在 Google Cloud DataStore 和 PHP 中获取新实体的密钥

问题描述

在 DataStore 的文档中提到了这个例子:

$task = $datastore->entity('Task', [
    'category' => 'Personal',
    'done' => false,
    'priority' => 4,
    'description' => 'Learn Cloud Datastore'
]);
$datastore->insert($task);

我想获取刚刚插入的这个新实体的密钥。

标签: phpgoogle-app-enginedatastore

解决方案


您可以使用类似于以下的语句:{const taskKey = datastore.key('Task');}

更多细节可以在检索实体子章节中找到。


推荐阅读