Routine

Routine

Routine objects are returned by methods such as Dataset#routine, Dataset#createRoutine, and Dataset#getRoutines.

Constructor

new Routine(dataset, id)

Parameters:
Name Type Description
dataset Dataset

Dataset instance.

id string

The ID of the routine.

Example
```
const {BigQuery} = require('@google-cloud/bigquery');
const bigquery = new BigQuery();
const dataset = bigquery.dataset('my-dataset');

const routine = dataset.routine('my_routine');
```

Methods

create(config, callbackopt) → {Promise.<CreateRoutineResponse>}

Create a routine.

See Routines: insert API Documentation

Parameters:
Name Type Attributes Description
config object

A routine resource.

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.

See Routines: delete API Documentation

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.

See Routines: get API Documentation

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.

See Routines: get API Documentation

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.

See Routines: update API Documentation

Parameters:
Name Type Attributes Description
metadata object

A routine resource 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);
```

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy