The geographic location of the table, by
default this value is inherited from the dataset. This can be used to
configure the location of all jobs created through a table instance. It
cannot be used to set the actual location of the table. This value will
be superseded by any API responses containing location data for the
table.
```
const {BigQuery} = require('@google-cloud/bigquery');
const bigquery = new BigQuery();
const dataset = bigquery.dataset('my-dataset');
const table = dataset.table('my-table');
table.createReadStream(options)
.on('error', console.error)
.on('data', row => {})
.on('end', function() {
// All rows have been retrieved.
});
//-
// If you anticipate many results, you can end a stream early to prevent
// unnecessary processing and API requests.
//-
table.createReadStream()
.on('data', function(row) {
this.end();
});
```
Metadata to set with the load operation.
The metadata object should be in the format of the
configuration.load
property of a Jobs resource. If a string is given,
it will be used as the filetype.
Properties
Name
Type
Attributes
Description
jobId
string
<optional>
Custom job id.
jobPrefix
string
<optional>
Prefix to apply to the job id.
Returns:
Type
Description
WritableStream
Throws:
If source format isn't recognized.
Type
Error
Example
```
const {BigQuery} = require('@google-cloud/bigquery');
const bigquery = new BigQuery();
const dataset = bigquery.dataset('my-dataset');
const table = dataset.table('my-table');
//-
// Load data from a CSV file.
//-
const request = require('request');
const csvUrl = 'http://goo.gl/kSE7z6';
const metadata = {
allowJaggedRows: true,
skipLeadingRows: 1
};
request.get(csvUrl)
.pipe(table.createWriteStream(metadata))
.on('job', (job) => {
// `job` is a Job object that can be used to check the status of the
// request.
})
.on('complete', (job) => {
// The job has completed successfully.
});
//-
// Load data from a JSON file.
//-
const fs = require('fs');
fs.createReadStream('./test/testdata/testfile.json')
.pipe(table.createWriteStream('json'))
.on('job', (job) => {
// `job` is a Job object that can be used to check the status of the
// request.
})
.on('complete', (job) => {
// The job has completed successfully.
});
```
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.
If you wish to get a selection of metadata instead of the full table metadata
(retrieved by both Table#get by default and by Table#getMetadata), use
the options parameter to set the view and/or selectedFields query parameters.
Wrap values
of 'INT64' type in BigQueryInt objects.
If a boolean, this will wrap values in BigQueryInt objects.
If an object, this will return a value returned by
wrapIntegers.integerTypeCastFunction.
```
const {BigQuery} = require('@google-cloud/bigquery');
const bigquery = new BigQuery();
const dataset = bigquery.dataset('my-dataset');
const table = dataset.table('my-table');
table.getRows((err, rows) => {
if (!err) {
// rows is an array of results.
}
});
//-
// To control how many API requests are made and page through the results
// manually, set `autoPaginate` to `false`.
//-
function manualPaginationCallback(err, rows, nextQuery, apiResponse) {
if (nextQuery) {
// More results exist.
table.getRows(nextQuery, manualPaginationCallback);
}
}
table.getRows({
autoPaginate: false
}, manualPaginationCallback);
//-
// If the callback is omitted, we'll return a Promise.
//-
table.getRows().then((data) => {
const rows = data[0];
});
```