Constructor
new Routine(dataset, id)
Parameters:
| Name | Type | Description | 
|---|---|---|
| dataset | Dataset | Dataset instance. | 
| id | string | The ID of the routine. | 
Methods
create(config, callbackopt) → {Promise.<CreateRoutineResponse>}
Create a routine.
Parameters:
| Name | Type | Attributes | Description | 
|---|---|---|---|
| config | object | ||
| callback | CreateRoutineCallback | <optional> | The callback function. | 
Returns:
| Type | Description | 
|---|---|
| Promise.<CreateRoutineResponse> | 
Examples
```
const {BigQuery} = require('@google-cloud/bigquery');
const bigquery = new BigQuery();
const dataset = bigquery.dataset('my-dataset');
const routine = dataset.routine('my_routine');
const config = {
  arguments: [{
    name: 'x',
    dataType: {
      typeKind: 'INT64'
    }
  }],
  definitionBody: 'x * 3',
  routineType: 'SCALAR_FUNCTION',
  returnType: {
    typeKind: 'INT64'
  }
};
routine.create(config, (err, routine, apiResponse) => {
  if (!err) {
    // The routine was created successfully.
  }
});
```If the callback is omitted a Promise will be returned
```
const [routine, apiResponse] = await routine.create(config);
```delete(callbackopt) → {Promise.<DeleteRoutineResponse>}
Deletes a routine.
Parameters:
| Name | Type | Attributes | Description | 
|---|---|---|---|
| callback | DeleteRoutineCallback | <optional> | The callback function. | 
Returns:
| Type | Description | 
|---|---|
| Promise.<DeleteRoutineResponse> | 
Examples
```
const {BigQuery} = require('@google-cloud/bigquery');
const bigquery = new BigQuery();
const dataset = bigquery.dataset('my-dataset');
const routine = dataset.routine('my_routine');
routine.delete((err, apiResponse) => {
  if (!err) {
    // The routine was deleted successfully.
  }
});
```If the callback is omitted a Promise will be returned
```
const [apiResponse] = await routine.delete();
```exists(callbackopt) → {Promise.<RoutineExistsResponse>}
Check if the routine exists.
Parameters:
| Name | Type | Attributes | Description | 
|---|---|---|---|
| callback | RoutineExistsCallback | <optional> | The callback function. | 
Returns:
| Type | Description | 
|---|---|
| Promise.<RoutineExistsResponse> | 
Examples
```
const {BigQuery} = require('@google-cloud/bigquery');
const bigquery = new BigQuery();
const dataset = bigquery.dataset('my-dataset');
const routine = dataset.routine('my_routine');
routine.exists((err, exists) => {});
```If the callback is omitted a Promise will be returned
```
const [exists] = await routine.exists();
```get(callbackopt) → {Promise.<GetRoutineResponse>}
Get a routine if it exists.
Parameters:
| Name | Type | Attributes | Description | 
|---|---|---|---|
| callback | GetRoutineCallback | <optional> | The callback function. | 
Returns:
| Type | Description | 
|---|---|
| Promise.<GetRoutineResponse> | 
Examples
```
const {BigQuery} = require('@google-cloud/bigquery');
const bigquery = new BigQuery();
const dataset = bigquery.dataset('my-dataset');
const routine = dataset.routine('my_routine');
routine.get((err, routine) => {});
```If the callback is omitted a Promise will be returned
```
const [routine2] = await routine.get();
```getMetadata(callbackopt) → {Promise.<GetRoutineMetadataResponse>}
Get the metadata associated with a routine.
Parameters:
| Name | Type | Attributes | Description | 
|---|---|---|---|
| callback | GetRoutineMetadataCallback | <optional> | The callback function. | 
Returns:
| Type | Description | 
|---|---|
| Promise.<GetRoutineMetadataResponse> | 
Examples
```
const {BigQuery} = require('@google-cloud/bigquery');
const bigquery = new BigQuery();
const dataset = bigquery.dataset('my-dataset');
const routine = dataset.routine('my_routine');
routine.getMetadata((err, metadata, apiResponse) => {});
```If the callback is omitted a Promise will be returned
```
const [metadata, apiResponse] = await routine.getMetadata();
```setMetadata(metadata, callbackopt) → {Promise.<SetRoutineMetadataResponse>}
Update a routine.
Parameters:
| Name | Type | Attributes | Description | 
|---|---|---|---|
| metadata | object | ||
| callback | SetRoutineMetadataCallback | <optional> | The callback function. | 
Returns:
| Type | Description | 
|---|---|
| Promise.<SetRoutineMetadataResponse> | 
Examples
```
const {BigQuery} = require('@google-cloud/bigquery');
const bigquery = new BigQuery();
const dataset = bigquery.dataset('my-dataset');
const routine = dataset.routine('my_routine');
const updates = {
  description: 'The perfect description!'
};
routine.setMetadata(updates, (err, metadata, apiResponse) => {});
```If the callback is omitted a Promise will be returned
```
const [metadata, apiResponse] = await routine.setMetadata(updates);
```