mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-28 21:33:15 -05:00
902ae750dc
Migrate scripts folder to esm 2/x GitOrigin-RevId: 1698bc4f13e026fa281d37a4914a2f997849c761
30 lines
628 B
JavaScript
30 lines
628 B
JavaScript
import { BigQuery as GoogleBigQuery } from '@google-cloud/bigquery'
|
|
|
|
let dataset = null
|
|
|
|
function getDataset() {
|
|
if (!dataset) {
|
|
console.log(
|
|
'Connecting to BigQuery dataset: ',
|
|
process.env.BQ_PROJECT_ID,
|
|
process.env.BQ_DATASET
|
|
)
|
|
|
|
dataset = new GoogleBigQuery({
|
|
projectId: process.env.BQ_PROJECT_ID,
|
|
keyFilename: process.env.GCS_KEY_FILE,
|
|
}).dataset(process.env.BQ_DATASET)
|
|
}
|
|
|
|
return dataset
|
|
}
|
|
|
|
async function query(query) {
|
|
const [job] = await getDataset().createQueryJob({ query })
|
|
const [rows] = await job.getQueryResults()
|
|
return rows
|
|
}
|
|
|
|
export default {
|
|
query,
|
|
}
|