Build a Datastore Key object.
Example 1
Example 1
//- // 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 2
Example 2
//- // 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 3
Example 3
//- // 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 4
Example 4
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']);