Helper library to easily use Google BigQuery in NodeJS
@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
}The project you'll use for billing.
The default dataset to connect to if it was not specified.
The credentials the connection will use.
Example:
{
"private_key": "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n",
"client_email": "[email protected]"
}More info about pricing: https://cloud.google.com/bigquery/pricing
const BigQuery = require('@emartech/google-big-query');Creates a BigQuery instance.
| Name | Type | Description |
|---|---|---|
datasetName |
string | The name of the default dataset. Default: config.GoogleCloud.datasetoptional |
| Type | Description |
|---|---|
| BigQuery | Instance of the BigQuery wrapper class. |
Constructor of BigQuery wrapper.
| Name | Type | Description |
|---|---|---|
datasetName |
string | The name of the default dataset. |
client |
@google-cloud/bigquery | The BigQuery client. |
Returns a Table instance for the given table name.
| Name | Type | Description |
|---|---|---|
tableName |
string | The name of the table in the dataset |
| Type | Description |
|---|---|
| Table | Google Cloud BigQuery Table class instance. |
This is a wrapper of the original createQueryStream() method.
| Name | Type | Description |
|---|---|---|
query |
string or object | The query to run. More info about the parameter. |
| Type | Description |
|---|---|
| ReadableStream |
This is a wrapper of the original query() method.
| Name | Type | Description |
|---|---|---|
query |
string or object | The query to run. More info about the parameter. |
| Type | Description |
|---|---|
| Promise |
This is a wrapper of the original createQueryJob() method.
| Name | Type | Description |
|---|---|---|
options |
object or string |
| Type | Description |
|---|---|
| Promise |
let [job] = yield BigQuery.create().createQueryJob(query);
job.getQueryResultsStream({ maxResults: 100000, startIndex: 0 }).pipe(processRow);Creates the table with the specified schema.
| Name | Type | Description |
|---|---|---|
table |
Table | The table instance |
schema |
object | Schema definition of the table |
| Type | Description |
|---|---|
| Table | The new Table. |
Drops the given table if exists.
| Name | Type | Description |
|---|---|---|
table |
Table | The table instance that should be dropped. |
This is a wrapper of the original createTable() method.
| Name | Type | Description |
|---|---|---|
tableName |
string | The name of the table. |
options |
object | More info in the original documentation. optional |
| Type | Description |
|---|---|
| Table | The new Table. |