Skip to content

Commit

Permalink
Renames for consistensy with other languages, composer updated.
Browse files Browse the repository at this point in the history
  • Loading branch information
Takashi Matsuo committed Oct 11, 2016
1 parent ae51a04 commit c4d12e7
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 86 deletions.
28 changes: 14 additions & 14 deletions datastore/api/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

79 changes: 40 additions & 39 deletions datastore/api/src/functions/concepts.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
*/
function initialize_client()
{
// [START init_client]
// [START initialize_client]
$datastore = new DatastoreClient();
// [END init_client]
// [END initialize_client]
return $datastore;
}

Expand All @@ -43,16 +43,16 @@ function initialize_client()
* @param DatastoreClient $datastore
* @return \Google\Cloud\Datastore\Entity
*/
function create_entity(DatastoreClient $datastore)
function basic_entity(DatastoreClient $datastore)
{
// [START create_entity]
// [START basic_entity]
$task = $datastore->entity('Task', [
'category' => 'Personal',
'done' => false,
'priority' => 4,
'description' => 'Learn Cloud Datastore'
]);
// [END create_entity]
// [END basic_entity]
return $task;
}

Expand All @@ -62,9 +62,9 @@ function create_entity(DatastoreClient $datastore)
* @param DatastoreClient $datastore
* @return \Google\Cloud\Datastore\Entity
*/
function upsert_entity(DatastoreClient $datastore)
function upsert(DatastoreClient $datastore)
{
// [START upsert_entity]
// [START upsert]
$key = $datastore->key('Task', 'sampleTask');
$task = $datastore->entity($key, [
'category' => 'Personal',
Expand All @@ -73,7 +73,7 @@ function upsert_entity(DatastoreClient $datastore)
'description' => 'Learn Cloud Datastore'
]);
$datastore->upsert($task);
// [END upsert_entity]
// [END upsert]

return $task;
}
Expand All @@ -85,17 +85,17 @@ function upsert_entity(DatastoreClient $datastore)
* @param DatastoreClient $datastore
* @return \Google\Cloud\Datastore\Entity
*/
function insert_entity(DatastoreClient $datastore)
function insert(DatastoreClient $datastore)
{
// [START insert_entity]
// [START insert]
$task = $datastore->entity('Task', [
'category' => 'Personal',
'done' => false,
'priority' => 4,
'description' => 'Learn Cloud Datastore'
]);
$datastore->insert($task);
// [END insert_entity]
// [END insert]
return $task;
}

Expand All @@ -107,10 +107,10 @@ function insert_entity(DatastoreClient $datastore)
*/
function lookup(DatastoreClient $datastore)
{
// [START lookup_entity]
// [START lookup]
$key = $datastore->key('Task', 'sampleTask');
$task = $datastore->lookup($key);
// [END lookup_entity]
// [END lookup]
return $task;
}

Expand All @@ -120,16 +120,16 @@ function lookup(DatastoreClient $datastore)
* @param DatastoreClient $datastore
* @return \Google\Cloud\Datastore\Entity|null
*/
function update_entity(DatastoreClient $datastore)
function update(DatastoreClient $datastore)
{
// [START update_entity]
// [START update]
$transaction = $datastore->transaction();
$key = $datastore->key('Task', 'sampleTask');
$task = $transaction->lookup($key);
$task['priority'] = 5;
$transaction->upsert($task);
$transaction->commit();
// [END update_entity]
// [END update]
return $task;
}

Expand All @@ -139,11 +139,11 @@ function update_entity(DatastoreClient $datastore)
* @param DatastoreClient $datastore
* @param Key $taskKey
*/
function delete_entity(DatastoreClient $datastore, Key $taskKey)
function delete(DatastoreClient $datastore, Key $taskKey)
{
// [START delete_entity]
// [START delete]
$datastore->delete($taskKey);
// [END delete_entity]
// [END delete]
}

/**
Expand All @@ -152,11 +152,11 @@ function delete_entity(DatastoreClient $datastore, Key $taskKey)
* @param DatastoreClient $datastore
* @param array <\Google\Cloud\Datastore\Entity> $tasks
*/
function upsert_multi(DatastoreClient $datastore, array $tasks)
function batch_upsert(DatastoreClient $datastore, array $tasks)
{
// [START upsert_multi]
// [START batch_upsert]
$datastore->upsertBatch($tasks);
// [END upsert_multi]
// [END batch_upsert]
}

/**
Expand All @@ -166,16 +166,16 @@ function upsert_multi(DatastoreClient $datastore, array $tasks)
* @param array <Key> $keys
* @return array <\Google\Cloud\Datastore\Entity>
*/
function lookup_multi(DatastoreClient $datastore, array $keys)
function batch_lookup(DatastoreClient $datastore, array $keys)
{
// [START lookup_multi]
// [START batch_lookup]
$result = $datastore->lookupBatch($keys);
if (isset($result['found'])) {
// $result['found'] is an array of entities.
} else {
// No entities found.
}
// [END lookup_multi]
// [END batch_lookup]
return $result;
}

Expand All @@ -185,11 +185,11 @@ function lookup_multi(DatastoreClient $datastore, array $keys)
* @param DatastoreClient $datastore
* @param array <Key> $keys
*/
function delete_multi(DatastoreClient $datastore, array $keys)
function batch_delete(DatastoreClient $datastore, array $keys)
{
// [START delete_multi]
// [START batch_delete]
$datastore->deleteBatch($keys);
// [END delete_multi]
// [END batch_delete]
}

/**
Expand All @@ -198,9 +198,9 @@ function delete_multi(DatastoreClient $datastore, array $keys)
* @param DatastoreClient $datastore
* @return Key
*/
function create_complete_key(DatastoreClient $datastore)
function named_key(DatastoreClient $datastore)
{
// [START names_key]
// [START named_key]
$taskKey = $datastore->key('Task', 'sampleTask');
// [END named_key]
return $taskKey;
Expand All @@ -212,7 +212,7 @@ function create_complete_key(DatastoreClient $datastore)
* @param DatastoreClient $datastore
* @return Key
*/
function create_incomplete_key(DatastoreClient $datastore)
function incomplete_key(DatastoreClient $datastore)
{
// [START incomplete_key]
$taskKey = $datastore->key('Task');
Expand All @@ -226,7 +226,7 @@ function create_incomplete_key(DatastoreClient $datastore)
* @param DatastoreClient $datastore
* @return Key
*/
function create_key_with_parent(DatastoreClient $datastore)
function key_with_parent(DatastoreClient $datastore)
{
// [START key_with_parent]
$taskKey = $datastore->key('TaskList', 'default')
Expand All @@ -241,13 +241,13 @@ function create_key_with_parent(DatastoreClient $datastore)
* @param DatastoreClient $datastore
* @return Key
*/
function create_key_with_multi_level_parent(DatastoreClient $datastore)
function key_with_multilevel_parent(DatastoreClient $datastore)
{
// [START key_with_multi_level_parent]
// [START key_with_multilevel_parent]
$taskKey = $datastore->key('User', 'alice')
->pathElement('TaskList', 'default')
->pathElement('Task', 'sampleTask');
// [END key_with_multi_level_parent]
// [END key_with_multilevel_parent]
return $taskKey;
}

Expand All @@ -258,21 +258,22 @@ function create_key_with_multi_level_parent(DatastoreClient $datastore)
* @param Key $key
* @return \Google\Cloud\Datastore\Entity
*/
function create_entity_with_option(DatastoreClient $datastore, Key $key)
function properties(DatastoreClient $datastore, Key $key)
{
// [START entity_with_option]
// [START properties]
$task = $datastore->entity(
$key,
[
'category' => 'Personal',
'created' => new \DateTime(),
'done' => false,
'priority' => 4,
'percent_complete' => 10.0,
'description' => 'Learn Cloud Datastore'
],
['excludeFromIndexes' => ['description']]
);
// [END entity_with_option]
// [END properties]
return $task;
}

Expand Down Expand Up @@ -303,7 +304,7 @@ function array_value(DatastoreClient $datastore, Key $key)
* @param DatastoreClient $datastore
* @return Query
*/
function create_basic_query(DatastoreClient $datastore)
function basic_query(DatastoreClient $datastore)
{
// [START basic_query]
$query = $datastore->query()
Expand Down
Loading

0 comments on commit c4d12e7

Please sign in to comment.