Model
Source: model.
Model objects are returned by methods such as Dataset#model and Dataset#getModels.
new Model(dataset, id)
Example
const {BigQuery} = require('@google-cloud/bigquery');
const bigquery = new BigQuery();
const dataset = bigquery.dataset('my-dataset');
const model = dataset.model('my-model');
Parameters
| Name | Type | Optional | Description |
|---|---|---|---|
|
dataset |
|
|
Dataset instance. |
|
id |
|
|
The ID of the model. |
Methods
delete([callback]) → Promise
Delete the model.
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) => {});
<caption>If the callback is omitted we'll return a Promise.
</caption>
const [apiResponse] = await model.delete();
Parameters
| Name | Type | Optional | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
callback |
function() |
Yes |
The callback function. Values in
|
- See also
- Returns
-
Promise
exists([callback]) → Promise
Check if the model exists.
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) => {});
<caption>If the callback is omitted we'll return a Promise.
</caption>
const [exists] = await model.exists();
Parameters
| Name | Type | Optional | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
callback |
function() |
Yes |
The callback function. Values in
|
- Returns
-
Promise
get:([callback]) → Promise
Get a model if it exists.
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.
}
});
<caption>If the callback is omitted we'll return a Promise.
</caption>
await model.get();
Parameters
| Name | Type | Optional | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
callback |
function() |
Yes |
The callback function. Values in
|
- See also
- Returns
-
Promise
getMetadata([callback]) → Promise
Return the metadata associated with the model.
Examples
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) => {});
<caption>If the callback is omitted we'll return a Promise.
</caption>
const [metadata, apiResponse] = await model.getMetadata();
Parameters
| Name | Type | Optional | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
callback |
function() |
Yes |
The callback function. Values in
|
- See also
- Returns
-
Promise
setMetadata(metadata[, callback]) → Promise
Examples
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) => {});
<caption>If the callback is omitted we'll return a Promise.
</caption>
const [metadata, apiResponse] = await model.setMetadata(metadata);
Parameters
| Name | Type | Optional | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
metadata |
object |
|
The metadata key/value object to set. |
||||||||||||||||
|
callback |
function() |
Yes |
The callback function. Values in
|
- See also
- Returns
-
Promise