4.0.1 • Published 3 years ago

@emartech/google-big-query v4.0.1

Weekly downloads
43
License
MIT
Repository
github
Last release
3 years ago

@emartech/google-big-query

Helper library to easily use Google BigQuery in NodeJS

Configuration

@emartech/google-big-query uses the config package for configuration. You should make the following settings available under `"GoogleCloud" namespace:

{
  "projectId": "",
  "bucket": "",
  "dataset": "",
  "credentials": {},
  "maximumBillingTier": 10
}

projectId

The project you'll use for billing.

dataset

The default dataset to connect to if it was not specified.

credentials

The credentials the connection will use.

Example:

{
  "private_key": "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n",
  "client_email": "example@my-service.iam.gserviceaccount.com"
}

maximumBillingTier

More info about pricing: https://cloud.google.com/bigquery/pricing

API

const BigQuery = require('@emartech/google-big-query');

BigQuery

Methods

create(datasetName):BigQuery static

Creates a BigQuery instance.

Parameters
NameTypeDescription
datasetNamestringThe name of the default dataset.Default: config.GoogleCloud.datasetoptional
Returns
TypeDescription
BigQueryInstance of the BigQuery wrapper class.

constructor(datasetName, client):BigQuery

Constructor of BigQuery wrapper.

Parameters
NameTypeDescription
datasetNamestringThe name of the default dataset.
client@google-cloud/bigqueryThe BigQuery client.

table(tableName):Table

Returns a Table instance for the given table name.

Parameters
NameTypeDescription
tableNamestringThe name of the table in the dataset
Returns
TypeDescription
TableGoogle Cloud BigQuery Table class instance.

createQueryStream(query):ReadableStream

This is a wrapper of the original createQueryStream() method.

Parameters
NameTypeDescription
querystring or objectThe query to run.More info about the parameter.
Returns
TypeDescription
ReadableStream

query(query):Promise

This is a wrapper of the original query() method.

Parameters
NameTypeDescription
querystring or objectThe query to run.More info about the parameter.
Returns
TypeDescription
Promise

createQueryJob(query):Promise generator

This is a wrapper of the original createQueryJob() method.

Parameters
NameTypeDescription
optionsobject or string
Returns
TypeDescription
Promise
Example
let [job] = yield BigQuery.create().createQueryJob(query);
job.getQueryResultsStream({ maxResults: 100000, startIndex: 0 }).pipe(processRow);

createTableIfNotExists(table, schema):Table generator

Creates the table with the specified schema.

Parameters
NameTypeDescription
tableTableThe table instance
schemaobjectSchema definition of the table
Returns
TypeDescription
TableThe new Table.

dropTableIfExists(table):void generator

Drops the given table if exists.

Parameters
NameTypeDescription
tableTableThe table instance that should be dropped.

createTable(tableName, options):Table generator

This is a wrapper of the original createTable() method.

Parameters
NameTypeDescription
tableNamestringThe name of the table.
optionsobjectMore info in the original documentation. optional
Returns
TypeDescription
TableThe new Table.

BigQuery.FileToTable

create(file, tableName, schema, options):FileToTable static

createWith(file, table, schema, options):FileToTable static

constructor(file, table, schema options):FileToTable

run():Job

BigQuery.QueryToFile

create(baseName, format, file):QueryToFile static

constructor(tableName, format, file):QueryToFile

run(query, options):File generator

BigQuery.QueryToFileToStream

create(baseName):QueryToFileToStream static

constructor(queryToFile):QueryToFileToStream

createQueryStream(query, options):JSONStream generator

BigQuery.QueryToStream

create():QueryToStream static

constructor(client):QueryToStream

run(query, parameters):ReadableStream

BigQuery.QueryToTable

create(tableName, dataset):QueryToTable static

constructor(client, tableName, dataset):QueryToTable

run(query, params):Job generator

BigQuery.QueryToView

create(viewName):QueryToView static

constructor(client, viewName):QueryToView

run():Table generator

BigQuery.StreamToTable

create(tableName, tableSchema):StreamToTable static

constructor(table, tableSchema):StreamToTable

saveStream():Promise

BigQuery.TableToFile

create(tableName, file, format):TableToFile static

constructor(table, file, format):TableToFile

run():Job generator

4.0.1

3 years ago

4.0.0

3 years ago

3.1.0

5 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.4.5

6 years ago

1.4.4

6 years ago

1.4.3

6 years ago

1.4.2

6 years ago

1.4.1

6 years ago

1.4.0

6 years ago

1.3.2

6 years ago

1.3.1

7 years ago

1.3.0

7 years ago

1.2.2

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago