method Query.prototype.runStream
Query.prototype.runStream(options?: RunQueryStreamOptions): import("stream").Transform

Run the query as a readable object stream.

Examples

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();
  });

Parameters

optional
options: RunQueryStreamOptions

Optional configuration. See Query#run for a complete list of options.

Return Type

import("stream").Transform

Usage

import { Query } from ".";