Models: List models, streaming

Lists all existing models in the dataset using streaming method.

Code Sample

Node.js

Before trying this sample, follow the Node.js setup instructions in the BigQuery Quickstart Using Client Libraries. For more information, see the BigQuery Node.js API reference documentation.


// Import the Google Cloud client library
const {BigQuery} = require('@google-cloud/bigquery');
const bigquery = new BigQuery();

async function listModels() {
  // Lists all existing models in the dataset using streaming method.

  /**
   * TODO(developer): Uncomment the following lines before running the sample.
   */
  // const datasetId = "my_dataset";

  const dataset = bigquery.dataset(datasetId);

  dataset
    .getModelsStream()
    .on('error', console.error)
    .on('data', model => {
      console.log(model.metadata);
    })
    .on('end', () => {
      console.log('All models have been retrieved.');
    });
}