Query.prototype.runStream(options?: RunQueryStreamOptions): import("stream").Transform
Run the query as a readable object stream.
Example 1
Example 1
const {Datastore} = require('@google-cloud/datastore'); const datastore = new Datastore(); const query = datastore.createQuery('Company'); query.runStream() .on('error', console.error) .on('data', function (entity) { // Access the Key object for this entity. const key = entity[datastore.KEY]; }) .on('info', (info) => {}) .on('end', () => { // All entities retrieved. }); //- // If you anticipate many results, you can end a stream early to prevent // unnecessary processing and API requests. //- query.runStream() .on('data', function (entity) { this.end(); });