diff --git a/src/entity.ts b/src/entity.ts index e89d572cf..b20f51d4b 100644 --- a/src/entity.ts +++ b/src/entity.ts @@ -174,10 +174,39 @@ export namespace entity { * @param {string} [options.namespace] Optional namespace. * * @example + * Create an incomplete key with a kind value of `Company`. * const {Datastore} = require('@google-cloud/datastore'); * const datastore = new Datastore(); + * const key = datastore.key('Company'); + * + * @example + * Create a complete key with a kind value of `Company` and id + * `123`. const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const key = datastore.key(['Company', 123]); + * + * @example + * If the ID integer is outside the bounds of a JavaScript Number + * object, create an Int. 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 + * Create a complete key from a provided namespace and + * path. const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); * const key = datastore.key({ - * namespace: 'ns', + * namespace: 'My-NS', * path: ['Company', 123] * }); */