Skip to content

Commit

Permalink
docs(key): copy Datastore#key examples to Key ctor (#306)
Browse files Browse the repository at this point in the history
  • Loading branch information
callmehiphop committed Jan 21, 2019
1 parent 8a4a985 commit 4cd6019
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion src/entity.ts
Expand Up @@ -174,10 +174,39 @@ export namespace entity {
* @param {string} [options.namespace] Optional namespace.
*
* @example
* <caption>Create an incomplete key with a kind value of `Company`.</caption>
* const {Datastore} = require('@google-cloud/datastore');
* const datastore = new Datastore();
* const key = datastore.key('Company');
*
* @example
* <caption>Create a complete key with a kind value of `Company` and id
* `123`.</caption> const {Datastore} = require('@google-cloud/datastore');
* const datastore = new Datastore();
* const key = datastore.key(['Company', 123]);
*
* @example
* <caption>If the ID integer is outside the bounds of a JavaScript Number
* object, create an Int.</caption> const {Datastore} =
* require('@google-cloud/datastore'); const datastore = new Datastore();
* const key = datastore.key([
* 'Company',
* datastore.int('100000000000001234')
* ]);
*
* @example
* const {Datastore} = require('@google-cloud/datastore');
* const datastore = new Datastore();
* // Create a complete key with a kind value of `Company` and name `Google`.
* // Note: `id` is used for numeric identifiers and `name` is used otherwise.
* const key = datastore.key(['Company', 'Google']);
*
* @example
* <caption>Create a complete key from a provided namespace and
* path.</caption> const {Datastore} = require('@google-cloud/datastore');
* const datastore = new Datastore();
* const key = datastore.key({
* namespace: 'ns',
* namespace: 'My-NS',
* path: ['Company', 123]
* });
*/
Expand Down

0 comments on commit 4cd6019

Please sign in to comment.