Query.prototype.run(options?: RunQueryOptions): Promise<RunQueryResponse>
Run the query.
Example 1
Example 1
const {Datastore} = require('@google-cloud/datastore'); const datastore = new Datastore(); const query = datastore.createQuery('Company'); query.run((err, entities, info) => { // entities = An array of records. // Access the Key object for an entity. const firstEntityKey = entities[0][datastore.KEY]; }); //- // A keys-only query returns just the keys of the result entities instead of // the entities themselves, at lower latency and cost. //- query.select('__key__'); query.run((err, entities) => { const keys = entities.map((entity) => { return entity[datastore.KEY]; }); }); //- // If the callback is omitted, we'll return a Promise. //- query.run().then((data) => { const entities = data[0]; });