Skip to content

Commit aac4192

Browse files
committed
Merge pull request #31 from pcostell/master
Update gcloud-node datastore snippets
2 parents 175cb0c + 5a4fd8e commit aac4192

File tree

2 files changed

+15
-23
lines changed

2 files changed

+15
-23
lines changed

datastore/concepts.js

+8-18
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ Entity.prototype.testLookup = function(callback) {
262262
// };
263263
}
264264
});
265-
// [End lookup]
265+
// [END lookup]
266266

267267
this.datastore.insert({
268268
key: taskKey,
@@ -337,7 +337,6 @@ Entity.prototype.testDelete = function(callback) {
337337
Entity.prototype.testBatchUpsert = function(callback) {
338338
datastore.key = this.datastore.key;
339339

340-
// [START batch_upsert]
341340
var taskKey1 = datastore.key(['Task', 1]);
342341
var taskKey2 = datastore.key(['Task', 2]);
343342

@@ -355,6 +354,7 @@ Entity.prototype.testBatchUpsert = function(callback) {
355354
description: 'Integrate Cloud Datastore'
356355
};
357356

357+
// [START batch_upsert]
358358
datastore.upsert([
359359
{
360360
key: taskKey1,
@@ -392,19 +392,9 @@ Entity.prototype.testBatchLookup = function(callback) {
392392
datastore.get([
393393
taskKey1,
394394
taskKey2
395-
], function(err, entities) {
395+
], function(err, tasks) {
396396
if (!err) {
397-
// entities[0].data = {
398-
// type: 'Personal',
399-
// done: false,
400-
// priority: 4,
401-
// description: 'Learn Cloud Datastore'
402-
// };
403-
404-
// entities[1].data = {
405-
// type: 'Work',
406-
// // ...
407-
// };
397+
// Tasks retrieved successfully.
408398
}
409399
});
410400
// [END batch_lookup]
@@ -651,12 +641,12 @@ Query.prototype.getProjectionQuery = function() {
651641
Query.prototype.getAncestorQuery = function() {
652642
var datastore = this.datastore;
653643

654-
// [START anscestor_query]
644+
// [START ancestor_query]
655645
var ancestorKey = datastore.key(['TaskList', 'default']);
656646

657647
var query = datastore.createQuery('Task')
658648
.hasAncestor(ancestorKey);
659-
// [END anscestor_query]
649+
// [END ancestor_query]
660650

661651
return query;
662652
};
@@ -852,11 +842,11 @@ Query.prototype.testArrayValueInequalityRange = function(callback) {
852842
Query.prototype.testArrayValueEquality = function(callback) {
853843
var datastore = this.datastore;
854844

855-
// [START array_value_equality_range]
845+
// [START array_value_equality]
856846
var query = datastore.createQuery('Task')
857847
.filter('tag =', 'fun')
858848
.filter('tag =', 'programming');
859-
// [END array_value_equality_range]
849+
// [END array_value_equality]
860850

861851
this.datastore.runQuery(query, callback);
862852
};

datastore/tasks.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
'use strict';
1515

16-
var gcloud = require('gcloud');
1716
var input = process.argv.splice(2);
1817
var command = input.shift();
1918

@@ -22,12 +21,16 @@ if (!projectId) {
2221
throw new Error('TEST_PROJECT_ID environment variable required.');
2322
}
2423

24+
// [START build_service]
25+
var gcloud = require('gcloud');
26+
2527
var datastore = gcloud.datastore({
2628
projectId: projectId
2729
});
30+
// [END build_service]
2831

2932
/*
30-
// [START build_service]
33+
Installation and setup instructions.
3134
1. Download the TaskList sample application from [here]
3235
(https://github.com/GoogleCloudPlatform/nodejs-docs-samples/archive/master.zip).
3336
@@ -61,7 +64,6 @@ export DATASTORE_PROJECT_ID=<project-id>
6164
```sh
6265
npm run tasks
6366
```
64-
// [END build_service]
6567
*/
6668

6769
// [START add_entity]
@@ -130,7 +132,7 @@ function listTasks(callback) {
130132
}
131133
// [END retrieve_entities]
132134

133-
// [START delete_task]
135+
// [START delete_entity]
134136
function deleteTask(taskId, callback) {
135137
var taskKey = datastore.key([
136138
'Task',
@@ -139,7 +141,7 @@ function deleteTask(taskId, callback) {
139141

140142
datastore.delete(taskKey, callback);
141143
}
142-
// [END delete_task]
144+
// [END delete_entity]
143145

144146
// [START format_results]
145147
function formatTasks(tasks) {

0 commit comments

Comments
 (0)