Constructor
new Model(dataset, id)
Parameters:
Name |
Type |
Description |
dataset |
Dataset
|
Dataset instance.
|
id |
string
|
The ID of the model.
|
Example
```
const {BigQuery} = require('@google-cloud/bigquery');
const bigquery = new BigQuery();
const dataset = bigquery.dataset('my-dataset');
const model = dataset.model('my-model');
```
Methods
delete(callbackopt) → {Promise}
Parameters:
Name |
Type |
Attributes |
Description |
callback |
DeleteModelCallback
|
<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:
Examples
```
const {BigQuery} = require('@google-cloud/bigquery');
const bigquery = new BigQuery();
const dataset = bigquery.dataset('my-dataset');
const model = dataset.model('my-model');
model.delete((err, apiResponse) => {});
```
If the callback is omitted we'll return a Promise.
```
const [apiResponse] = await model.delete();
```
If successful, the response body is empty.
```
```
Check if the model exists.
Parameters:
Name |
Type |
Attributes |
Description |
callback |
ModelExistsCallback
|
<optional>
|
The callback function.
Properties
Name |
Type |
Attributes |
Description |
err |
error
|
<nullable>
|
An error returned while making this
request.
|
exists |
boolean
|
|
Whether the model exists or not.
|
|
Returns:
Examples
```
const {BigQuery} = require('@google-cloud/bigquery');
const bigquery = new BigQuery();
const dataset = bigquery.dataset('my-dataset');
const model = dataset.model('my-model');
model.exists((err, exists) => {});
```
If the callback is omitted we'll return a Promise.
```
const [exists] = await model.exists();
```
Parameters:
Name |
Type |
Attributes |
Description |
callback |
GetModelCallback
|
<optional>
|
The callback function.
Properties
Name |
Type |
Attributes |
Description |
err |
error
|
<nullable>
|
An error returned while making this
request.
|
model |
Model
|
|
The Model.
|
apiResponse |
object
|
|
The full API response.
|
|
Returns:
Examples
```
const {BigQuery} = require('@google-cloud/bigquery');
const bigquery = new BigQuery();
const dataset = bigquery.dataset('my-dataset');
const model = dataset.model('my-model');
model.get(err => {
if (!err) {
// `model.metadata` has been populated.
}
});
```
If the callback is omitted we'll return a Promise.
```
await model.get();
```
Parameters:
Name |
Type |
Attributes |
Description |
callback |
GetModelMetadataCallback
|
<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 model.
|
apiResponse |
object
|
|
The full API response.
|
|
Returns:
```
const {BigQuery} = require('@google-cloud/bigquery');
const bigquery = new BigQuery();
const dataset = bigquery.dataset('my-dataset');
const model = dataset.model('my-model');
model.getMetadata((err, metadata, apiResponse) => {});
```
If the callback is omitted we'll return a Promise.
```
const [metadata, apiResponse] = await model.getMetadata();
```
Parameters:
Name |
Type |
Attributes |
Description |
metadata |
object
|
|
The metadata key/value object to set.
|
callback |
SetModelMetadataCallback
|
<optional>
|
The callback function.
Properties
Name |
Type |
Attributes |
Description |
err |
error
|
<nullable>
|
An error returned while making this
request.
|
metadata |
object
|
|
The updated metadata of the model.
|
apiResponse |
object
|
|
The full API response.
|
|
Returns:
```
const {BigQuery} = require('@google-cloud/bigquery');
const bigquery = new BigQuery();
const dataset = bigquery.dataset('my-dataset');
const model = dataset.model('my-model');
const metadata = {
friendlyName: 'TheBestModelEver'
};
model.setMetadata(metadata, (err, metadata, apiResponse) => {});
```
If the callback is omitted we'll return a Promise.
```
const [metadata, apiResponse] = await model.setMetadata(metadata);
```