Constructor
new Dataset(bigQuery, id, optionsopt)
Parameters:
| Name | Type | Attributes | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| bigQuery | BigQuery | BigQuery instance. | |||||||||
| id | string | The ID of the Dataset. | |||||||||
| options | object | <optional> | Dataset options. Properties
 | 
Methods
create(callbackopt) → {Promise.<CreateDatasetResponse>}
Create a dataset.
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| callback | CreateDatasetCallback | <optional> | The callback function. Properties
 | 
Returns:
| Type | Description | 
|---|---|
| Promise.<CreateDatasetResponse> | 
Example
```
const {BigQuery} = require('@google-cloud/bigquery');
const bigquery = new BigQuery();
const dataset = bigquery.dataset('institutions');
dataset.create((err, dataset, apiResponse) => {
  if (!err) {
    // The dataset was created successfully.
  }
});
//-
// If the callback is omitted, we'll return a Promise.
//-
dataset.create().then((data) => {
  const dataset = data[0];
  const apiResponse = data[1];
});
```createQueryStream(options) → {stream}
Run a query scoped to your dataset as a readable object stream.
See BigQuery#createQueryStream for full documentation of this method.
Parameters:
| Name | Type | Description | 
|---|---|---|
| options | object | See BigQuery#createQueryStream for full documentation of this method. | 
Returns:
| Type | Description | 
|---|---|
| stream | 
exists(callbackopt) → {Promise.<DatasetExistsResponse>}
Check if the dataset exists.
Parameters:
| Name | Type | Attributes | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| callback | DatasetExistsCallback | <optional> | The callback function. Properties
 | 
Returns:
| Type | Description | 
|---|---|
| Promise.<DatasetExistsResponse> | 
Example
```
const {BigQuery} = require('@google-cloud/bigquery');
const bigquery = new BigQuery();
const dataset = bigquery.dataset('institutions');
dataset.exists((err, exists) => {});
//-
// If the callback is omitted, we'll return a Promise.
//-
dataset.exists().then((data) => {
  const exists = data[0];
});
```get(optionsopt, callbackopt) → {Promise.<GetDatasetResponse>}
Get a dataset if it exists.
You may optionally use this to "get or create" an object by providing
an object with autoCreate set to true. Any extra configuration that
is normally required for the create method must be contained within
this object as well.
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| options | options | <optional> | Configuration object. Properties
 | ||||||||||||||||
| callback | GetDatasetCallback | <optional> | The callback function. Properties
 | 
Returns:
| Type | Description | 
|---|---|
| Promise.<GetDatasetResponse> | 
Example
```
const {BigQuery} = require('@google-cloud/bigquery');
const bigquery = new BigQuery();
const dataset = bigquery.dataset('institutions');
dataset.get((err, dataset, apiResponse) => {
  if (!err) {
    // `dataset.metadata` has been populated.
  }
});
//-
// If the callback is omitted, we'll return a Promise.
//-
dataset.get().then((data) => {
  const dataset = data[0];
  const apiResponse = data[1];
});
```getMetadata(callbackopt) → {Promise.<GetDatasetMetadataResponse>}
Get the metadata for the Dataset.
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| callback | GetDatasetMetadataCallback | <optional> | The callback function. Properties
 | 
Returns:
| Type | Description | 
|---|---|
| Promise.<GetDatasetMetadataResponse> | 
Example
```
const {BigQuery} = require('@google-cloud/bigquery');
const bigquery = new BigQuery();
const dataset = bigquery.dataset('institutions');
dataset.getMetadata((err, metadata, apiResponse) => {});
//-
// If the callback is omitted, we'll return a Promise.
//-
dataset.getMetadata().then((data) => {
  const metadata = data[0];
  const apiResponse = data[1];
});
```getModelsStream(optionsopt) → {stream}
List all or some of the Model objects in your project as a readable object stream.
Parameters:
| Name | Type | Attributes | Description | 
|---|---|---|---|
| options | object | <optional> | Configuration object. See Dataset#getModels for a complete list of options. | 
Returns:
| Type | Description | 
|---|---|
| stream | 
Examples
```
const {BigQuery} = require('@google-cloud/bigquery');
const bigquery = new BigQuery();
const dataset = bigquery.dataset('institutions');
dataset.getModelsStream()
  .on('error', console.error)
  .on('data', (model) => {})
  .on('end', () => {
    // All models have been retrieved
  });
```If you anticipate many results, you can end a stream early to prevent unnecessary processing and API requests.
```
dataset.getModelsStream()
  .on('data', function(model) {
    this.end();
  });
```getRoutinesStream(optionsopt) → {stream}
List all or some of the Routine objects in your project as a readable object stream.
Parameters:
| Name | Type | Attributes | Description | 
|---|---|---|---|
| options | GetRoutinesOptions | <optional> | Configuration object. | 
Returns:
| Type | Description | 
|---|---|
| stream | 
Examples
```
const {BigQuery} = require('@google-cloud/bigquery');
const bigquery = new BigQuery();
const dataset = bigquery.dataset('institutions');
dataset.getRoutinesStream()
  .on('error', console.error)
  .on('data', (routine) => {})
  .on('end', () => {
    // All routines have been retrieved
  });
```If you anticipate many results, you can end a stream early to prevent unnecessary processing and API requests.
```
dataset.getRoutinesStream()
  .on('data', function(routine) {
    this.end();
  });
```getTablesStream(optionsopt) → {stream}
List all or some of the Table objects in your project as a readable object stream.
Parameters:
| Name | Type | Attributes | Description | 
|---|---|---|---|
| options | object | <optional> | Configuration object. See Dataset#getTables for a complete list of options. | 
Returns:
| Type | Description | 
|---|---|
| stream | 
Example
```
const {BigQuery} = require('@google-cloud/bigquery');
const bigquery = new BigQuery();
const dataset = bigquery.dataset('institutions');
dataset.getTablesStream()
  .on('error', console.error)
  .on('data', (table) => {})
  .on('end', () => {
    // All tables have been retrieved
  });
//-
// If you anticipate many results, you can end a stream early to prevent
// unnecessary processing and API requests.
//-
dataset.getTablesStream()
  .on('data', function(table) {
    this.end();
  });
```model(id) → {Model}
Create a Model object.
Parameters:
| Name | Type | Description | 
|---|---|---|
| id | string | The ID of the model. | 
Returns:
| Type | Description | 
|---|---|
| Model | 
Throws:
- 
      if model ID is missing. 
- Type
- TypeError
Example
```
const {BigQuery} = require('@google-cloud/bigquery');
const bigquery = new BigQuery();
const dataset = bigquery.dataset('institutions');
const model = dataset.model('my-model');
```routine(id) → {Routine}
Create a Routine object.
Parameters:
| Name | Type | Description | 
|---|---|---|
| id | string | The ID of the routine. | 
Returns:
| Type | Description | 
|---|---|
| Routine | 
Throws:
- 
      if routine ID is missing. 
- Type
- TypeError
Example
```
const {BigQuery} = require('@google-cloud/bigquery');
const bigquery = new BigQuery();
const dataset = bigquery.dataset('institutions');
const routine = dataset.routine('my_routine');
```setMetadata(metadata, callbackopt) → {Promise.<SetDatasetMetadataResponse>}
Sets the metadata of the Dataset object.
Parameters:
| Name | Type | Attributes | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| metadata | object | Metadata to save on the Dataset. | |||||||||||||
| callback | SetDatasetMetadataCallback | <optional> | The callback function. Properties
 | 
Returns:
| Type | Description | 
|---|---|
| Promise.<SetDatasetMetadataResponse> | 
Example
```
const {BigQuery} = require('@google-cloud/bigquery');
const bigquery = new BigQuery();
const dataset = bigquery.dataset('institutions');
const metadata = {
  description: 'Info for every institution in the 2013 IPEDS universe'
};
dataset.setMetadata(metadata, (err, apiResponse) => {});
//-
// If the callback is omitted, we'll return a Promise.
//-
dataset.setMetadata(metadata).then((data) => {
  const apiResponse = data[0];
});
```table(id, optionsopt) → {Table}
Create a Table object.
Parameters:
| Name | Type | Attributes | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| id | string | The ID of the table. | |||||||||
| options | object | <optional> | Table options. Properties
 | 
Returns:
| Type | Description | 
|---|---|
| Table | 
Throws:
- 
      if table ID is missing. 
- Type
- TypeError