Currently in my company, people use a bigquery handler from a file bigquery.ts
import {query} from 'biquery.ts'
query.doSomeStuff(...)
In this bigquery.ts file I've got a top level:
const BQ = new BigQuery({
credentials:...
scopes: ...
});
export async function query<T>(
query: string,
params = {},
labels = {}
): Promise<T[]> {
const [job] = await BQ.createQueryJob({
...
}
I have trouble understanding if this implementation would benefit to be in a BigQueryService to be used with DI, and why would it be seen as good practice?
- Parameters of the BigQuery object don't change
Why having it as a dependency would be cleaner than doing a:
import {query} from 'biquery.ts'
Each time I need it?