@@ -146,9 +146,14 @@ class Entity extends TestHelper {
146146 }
147147
148148 testEntityWithParent ( ) {
149- const taskKey = this . keyWithParent ;
150-
151149 // [START datastore_entity_with_parent]
150+ const taskKey = datastore . key ( [
151+ 'TaskList' ,
152+ 'default' ,
153+ 'Task' ,
154+ 'sampleTask' ,
155+ ] ) ;
156+
152157 const task = {
153158 key : taskKey ,
154159 data : {
@@ -222,10 +227,15 @@ class Entity extends TestHelper {
222227 }
223228
224229 async testUpsert ( ) {
225- const taskKey = this . getIncompleteKey ( ) ;
226- const task = this . getTask ( ) ;
227-
228230 // [START datastore_upsert]
231+ const taskKey = datastore . key ( 'Task' ) ;
232+ const task = {
233+ category : 'Personal' ,
234+ done : false ,
235+ priority : 4 ,
236+ description : 'Learn Cloud Datastore' ,
237+ } ;
238+
229239 const entity = {
230240 key : taskKey ,
231241 data : task ,
@@ -242,10 +252,15 @@ class Entity extends TestHelper {
242252 }
243253
244254 testInsert ( ) {
245- const taskKey = this . getIncompleteKey ( ) ;
246- const task = this . getTask ( ) ;
247-
248255 // [START datastore_insert]
256+ const taskKey = datastore . key ( 'Task' ) ;
257+ const task = {
258+ category : 'Personal' ,
259+ done : false ,
260+ priority : 4 ,
261+ description : 'Learn Cloud Datastore' ,
262+ } ;
263+
249264 const entity = {
250265 key : taskKey ,
251266 data : task ,
@@ -264,9 +279,8 @@ class Entity extends TestHelper {
264279 }
265280
266281 async testLookup ( ) {
267- const taskKey = this . getIncompleteKey ( ) ;
268-
269282 // [START datastore_lookup]
283+ const taskKey = datastore . key ( 'Task' ) ;
270284 const [ entity ] = await datastore . get ( taskKey ) ;
271285 // entity = {
272286 // category: 'Personal',
@@ -294,10 +308,15 @@ class Entity extends TestHelper {
294308 }
295309
296310 async testUpdate ( ) {
297- const taskKey = this . getIncompleteKey ( ) ;
298- const task = this . getTask ( ) ;
299-
300311 // [START datastore_update]
312+ const taskKey = datastore . key ( 'Task' ) ;
313+ const task = {
314+ category : 'Personal' ,
315+ done : false ,
316+ priority : 4 ,
317+ description : 'Learn Cloud Datastore' ,
318+ } ;
319+
301320 const entity = {
302321 key : taskKey ,
303322 data : task ,
@@ -316,9 +335,8 @@ class Entity extends TestHelper {
316335 }
317336
318337 async testDelete ( ) {
319- const taskKey = this . getIncompleteKey ( ) ;
320-
321338 // [START datastore_delete]
339+ const taskKey = datastore . key ( 'Task' ) ;
322340 await datastore . delete ( taskKey ) ;
323341 // Task deleted successfully.
324342 // [END datastore_delete]
@@ -331,6 +349,7 @@ class Entity extends TestHelper {
331349 }
332350
333351 async testBatchUpsert ( ) {
352+ // [START datastore_batch_upsert]
334353 const taskKey1 = this . datastore . key ( [ 'Task' , 1 ] ) ;
335354 const taskKey2 = this . datastore . key ( [ 'Task' , 2 ] ) ;
336355
@@ -348,7 +367,6 @@ class Entity extends TestHelper {
348367 description : 'Integrate Cloud Datastore' ,
349368 } ;
350369
351- // [START datastore_batch_upsert]
352370 const entities = [
353371 {
354372 key : taskKey1 ,
@@ -377,10 +395,10 @@ class Entity extends TestHelper {
377395 }
378396
379397 async testBatchLookup ( ) {
398+ // [START datastore_batch_lookup]
380399 const taskKey1 = this . datastore . key ( [ 'Task' , 1 ] ) ;
381400 const taskKey2 = this . datastore . key ( [ 'Task' , 2 ] ) ;
382401
383- // [START datastore_batch_lookup]
384402 const keys = [ taskKey1 , taskKey2 ] ;
385403
386404 const [ tasks ] = await datastore . get ( keys ) ;
@@ -392,10 +410,10 @@ class Entity extends TestHelper {
392410 }
393411
394412 async testBatchDelete ( ) {
413+ // [START datastore_batch_delete]
395414 const taskKey1 = this . datastore . key ( [ 'Task' , 1 ] ) ;
396415 const taskKey2 = this . datastore . key ( [ 'Task' , 2 ] ) ;
397416
398- // [START datastore_batch_delete]
399417 const keys = [ taskKey1 , taskKey2 ] ;
400418
401419 await datastore . delete ( keys ) ;
0 commit comments