Interact with your BigQuery dataset. Create a Dataset instance withBigQuery#createDataset orBigQuery#dataset.
| Name | Type | Attributes | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
bigQuery | BigQuery | BigQuery instance. | |||||||||||||
id | string | The ID of the Dataset. | |||||||||||||
options | object | <optional> | Dataset options. Properties
|
Create a dataset.
| Name | Type | Attributes | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
callback | CreateDatasetCallback | <optional> | The callback function. Properties
|
| Type | Description |
|---|---|
| Promise.<CreateDatasetResponse> |
```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];});```Run a query scoped to your dataset as a readable object stream.
SeeBigQuery#createQueryStream for full documentation of thismethod.
| Name | Type | Description |
|---|---|---|
options | object | SeeBigQuery#createQueryStream for fulldocumentation of this method. |
| Type | Description |
|---|---|
| stream |
Check if the dataset exists.
| Name | Type | Attributes | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
callback | DatasetExistsCallback | <optional> | The callback function. Properties
|
| Type | Description |
|---|---|
| Promise.<DatasetExistsResponse> |
```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 a dataset if it exists.
You may optionally use this to "get or create" an object by providingan object withautoCreate set totrue. Any extra configuration thatis normally required for thecreate method must be contained withinthis object as well.
| Name | Type | Attributes | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | options | <optional> | Configuration object. Properties
| ||||||||||||||||
callback | GetDatasetCallback | <optional> | The callback function. Properties
|
| Type | Description |
|---|---|
| Promise.<GetDatasetResponse> |
```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];});```Get the metadata for the Dataset.
| Name | Type | Attributes | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
callback | GetDatasetMetadataCallback | <optional> | The callback function. Properties
|
| Type | Description |
|---|---|
| Promise.<GetDatasetMetadataResponse> |
```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];});```List all or some of theModel objects in your projectas a readable object stream.
| Name | Type | Attributes | Description |
|---|---|---|---|
options | object | <optional> | Configuration object. SeeDataset#getModels for a complete list of options. |
| Type | Description |
|---|---|
| stream |
```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(); });```List all or some of theRoutine objects in your project as areadable object stream.
| Name | Type | Attributes | Description |
|---|---|---|---|
options | GetRoutinesOptions | <optional> | Configuration object. |
| Type | Description |
|---|---|
| stream |
```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(); });```List all or some of theTable objects in your projectas a readable object stream.
| Name | Type | Attributes | Description |
|---|---|---|---|
options | object | <optional> | Configuration object. SeeDataset#getTables for a complete list of options. |
| Type | Description |
|---|---|
| stream |
```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(); });```Create aModel object.
| Name | Type | Description |
|---|---|---|
id | string | The ID of the model. |
| Type | Description |
|---|---|
| Model |
if model ID is missing.
```const {BigQuery} = require('@google-cloud/bigquery');const bigquery = new BigQuery();const dataset = bigquery.dataset('institutions');const model = dataset.model('my-model');```Create aRoutine object.
| Name | Type | Description |
|---|---|---|
id | string | The ID of the routine. |
| Type | Description |
|---|---|
| Routine |
if routine ID is missing.
```const {BigQuery} = require('@google-cloud/bigquery');const bigquery = new BigQuery();const dataset = bigquery.dataset('institutions');const routine = dataset.routine('my_routine');```Sets the metadata of the Dataset object.
| Name | Type | Attributes | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
metadata | object | Metadata to save on the Dataset. | |||||||||||||
callback | SetDatasetMetadataCallback | <optional> | The callback function. Properties
|
| Type | Description |
|---|---|
| Promise.<SetDatasetMetadataResponse> |
```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];});```Create aTable object.
| Name | Type | Attributes | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
id | string | The ID of the table. | |||||||||
options | object | <optional> | Table options. Properties
|
| Type | Description |
|---|---|
| Table |
if table ID is missing.