Constructor
new Job(bigQuery, id, optionsopt )
Parameters:
Name
Type
Attributes
Description
bigQuery
BigQuery
BigQuery instance.
id
string
The ID of the job.
options
object
<optional>
Configuration object.
Properties
Name
Type
Attributes
Description
location
string
<optional>
The geographic location of the job.
Required except for US and EU.
Example
```
const {BigQuery} = require ('@google-cloud/bigquery' );
const bigquery = new BigQuery();
const job = bigquery.job('job-id' );
job.on('complete' , (metadata) => {
});
job.on('error' , (err) => {
});
job.removeAllListeners();
```
Members
getQueryResultsStream
Get the results of a job as a readable object stream.
Example
` ``
const through2 = require ('through2' );
const fs = require ('fs' );
const {BigQuery} = require ('@google-cloud/bigquery' );
const bigquery = new BigQuery();
const job = bigquery.job('job-id' );
job.getQueryResultsStream()
.pipe(through2.obj(function (row, enc, next ) {
this .push(JSON .stringify(row) + '\n' );
next();
}))
.pipe(fs.createWriteStream('./test/testdata/testfile.json' ));
`` `
Methods
Parameters:
Name
Type
Attributes
Description
callback
DeleteJobCallback
<optional>
The callback function.
Properties
Name
Type
Attributes
Description
err
error
<nullable>
An error returned while making this
request.
apiResponse
object
The full API response.
Returns:
See:
Examples
const {BigQuery} = require ('@google-cloud/bigquery' );
const bigquery = new BigQuery();
const job = bigquery.job(jobId);
job.delete((err, apiResponse ) => {
if (!err) {
}
});
If the callback is omitted a Promise will be returned
const [apiResponse] = await job.delete();
Parameters:
Name
Type
Attributes
Description
callback
JobExistsCallback
<optional>
The callback function.
Properties
Name
Type
Attributes
Description
err
error
<nullable>
An error returned while making this
request.
exists
boolean
Whether the job exists or not.
Returns:
Example
` ``
const {BigQuery} = require ('@google-cloud/bigquery' );
const bigquery = new BigQuery();
const job = bigquery.job('job-id' );
job.exists((err, exists ) => {});
job.exists().then((data ) => {
const exists = data[0 ];
});
`` `
get(optionsopt , callbackopt ) → {Promise.<GetJobResponse >}
Parameters:
Name
Type
Attributes
Description
options
object
<optional>
Configuration object.
Properties
Name
Type
Attributes
Description
location
string
<optional>
The geographic location of the job.
Required except for US and EU.
callback
GetJobCallback
<optional>
The callback function.
Properties
Name
Type
Attributes
Description
err
error
<nullable>
An error returned while making this
request.
job
Job
The job.
Returns:
Example
` ``
const {BigQuery} = require ('@google-cloud/bigquery' );
const bigquery = new BigQuery();
const job = bigquery.job('job-id' );
job.get((err, job, apiResponse ) => {
if (!err) {
`job.metadata` has been populated.
}
});
job.get().then((data ) => {
const job = data[0 ];
const apiResponse = data[1 ];
});
`` `
Get the metadata of the job. This will mostly be useful for checking
the status of a previously-run job.
See Jobs: get API Documentation
Parameters:
Name
Type
Attributes
Description
callback
GetJobMetadataCallback
<optional>
The callback function.
Properties
Name
Type
Attributes
Description
err
error
<nullable>
An error returned while making this
request.
metadata
object
The metadata of the job.
apiResponse
object
The full API response.
Returns:
` ``
const {BigQuery} = require ('@google-cloud/bigquery' );
const bigquery = new BigQuery();
const job = bigquery.job('id' );
job.getMetadata((err, metadata, apiResponse ) => {});
job.getMetadata().then((data ) => {
const metadata = data[0 ];
const apiResponse = data[1 ];
});
`` `