9999Get operations require a valid key to retrieve the key identified entity from Datastore. Skip to the "Querying" section if you'd like to learn more about querying against Datastore.
100100
101101~~~~ js
102- ds .get (datastore .key (' Company' , 123 ), function (err , entity ) {});
102+ ds .get (ds .key (' Company' , 123 ), function (err , entity ) {});
103103
104104// alternatively, you can retrieve multiple entities at once.
105105ds .get ([
106- datastore .key (' Company' , 123 ),
107- datastore .key (' Product' , ' Computer' )
106+ ds .key (' Company' , 123 ),
107+ ds .key (' Product' , ' Computer' )
108108], function (err , entities ) {});
109109~~~~
110110
@@ -114,15 +114,15 @@ To learn more about keys and incomplete keys, skip to the Keys section.
114114
115115~~~~ js
116116ds .save ({
117- key: datastore .key (' Company' , null ), data: {/* ...*/ }
117+ key: ds .key (' Company' , null ), data: {/* ...*/ }
118118}, function (err , key ) {
119119 // First arg is an incomplete key for Company kind.
120120 // console.log(key) will output ['Company', 599900452312].
121121});
122122// alternatively, you can save multiple entities at once.
123123ds .save ([
124- { key: datastore .key (' Company' , 123 ), data: {/* ...*/ } },
125- { key: datastore .key (' Product' , ' Computer' ), data: {/* ...*/ } }
124+ { key: ds .key (' Company' , 123 ), data: {/* ...*/ } },
125+ { key: ds .key (' Product' , ' Computer' ), data: {/* ...*/ } }
126126], function (err , keys ) {
127127 // if the first key was incomplete, keys[0] will return the generated key.
128128});
@@ -136,10 +136,10 @@ ds.delete(['Company', 599900452312], function(err) {});
136136// alternatively, you can delete multiple entities of different
137137// kinds at once.
138138ds .delete ([
139- datastore .key (' Company' , 599900452312 ),
140- datastore .key (' Company' , 599900452315 ),
141- datastore .key (' Office' , ' mtv' ),
142- datastore .key (' Company' , 123 , ' Employee' , ' jbd' )
139+ ds .key (' Company' , 599900452312 ),
140+ ds .key (' Company' , 599900452315 ),
141+ ds .key (' Office' , ' mtv' ),
142+ ds .key (' Company' , 123 , ' Employee' , ' jbd' )
143143], function (err ) {});
144144~~~~
145145
@@ -178,14 +178,14 @@ stored as properties is not currently supported.
178178
179179~~~~ js
180180var q = ds .createQuery (' Company' )
181- .filter (' __key__ =' , datastore .key (' Company' , ' Google' ))
181+ .filter (' __key__ =' , ds .key (' Company' , ' Google' ))
182182~~~~
183183
184184In order to filter by ancestors, use ` hasAncestor ` helper.
185185
186186~~~ js
187187var q = ds .createQuery (' Child' )
188- .hasAncestor (datastore .key (' Parent' , 123 ));
188+ .hasAncestor (ds .key (' Parent' , 123 ));
189189~~~
190190
191191##### Sorting
@@ -223,25 +223,14 @@ var q = ds.createQuery('Company')
223223#### Allocating IDs (ID generation)
224224
225225You can generate IDs without creating entities. The following call will create
226- 100 new IDs from the Company kind which exists under the default namespace.
226+ 100 new IDs from the Company kind which exists under the dataset's namespace.
227227
228228~~~~ js
229- ds .allocateIds (datastore .key (' Company' , null ), 100 , function (err , keys ) {
229+ ds .allocateIds (ds .key (' Company' , null ), 100 , function (err , keys ) {
230230
231231});
232232~~~~
233233
234- You may prefer to create IDs from a non-default namespace by providing
235- an incomplete key with a namespace. Similar to the previous example, the
236- call below will create 100 new IDs, but from the Company kind that exists
237- under the "ns-test" namespace.
238-
239- ~~~~ js
240- var incompleteKey = datastore .key (' ns-test' , ' Company' , null );
241- ds .allocateIds (incompleteKey, 100 , function (err , keys ) {
242- });
243- ~~~~
244-
245234#### Transactions
246235
247236Datastore has support for transactions. Transactions allow you to perform
0 commit comments