bigquery-client
Version:
A feature-rich Node.js client for Google BigQuery with support for CRUD operations, transactions, query building, and advanced features like aggregate functions, pagination, and logging.
35 lines (34 loc) • 819 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Transaction = void 0;
class Transaction {
constructor(client) {
this.queries = [];
this.client = client;
}
/**
*
* @param query query to run
* @param params query params
*/
addQuery(query, params = []) {
this.queries.push({ query, params });
}
/**
* Execute all queries in the transaction
* @returns
*
*/
async excute() {
try {
for (const { query, params } of this.queries) {
await this.client.query(query, params);
}
}
catch (error) {
console.error('Error executing transaction', error);
throw error;
}
}
}
exports.Transaction = Transaction;