Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Read from BigQuery via Firebase Function
const functions = require("firebase-functions");
const {BigQuery} = require('@google-cloud/bigquery');
exports.getMostPolluted = functions.https.onCall((data, context) => {
const bigQuery = new BigQuery();
const query = 'SELECT location, city, country, value, timestamp FROM `bigquery-public-data.openaq.global_air_quality` WHERE pollutant = "pm25" AND timestamp > "2020-01-01" ORDER BY value DESC LIMIT 10';
return bigQuery.query(query)
.then(function(data) {
const rows = data[0];
return rows;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment