【发布时间】:2019-04-30 13:21:02
【问题描述】:
我正在尝试使用 firebase 云功能从 BigQuery 表中获取一些数据到我的 React 前端。
我的表有 14000 多行,所以我不想同时将它们全部带入,我更愿意发送请求一次获得 100 左右。
我在这里查看了文档:https://cloud.google.com/bigquery/docs/managing-table-data#browse-table
但他们的解决方案似乎对返回的内容没有任何影响。
exports.getTableDataFromFrontEnd = functions.runWith(runtimeOpts).https.onCall((data, context) => {
console.log('V23');
let promise = new Promise(function(resolve, reject) {
async function browseRows() {
// Create a client
const bigqueryClient = new BigQuery();
const datasetId = 'CSV_Upload';
const tableId = 'Test_Table';
//Limit the query to 100 rows (This is not working).
const options = {
limit: 100
};
// List rows in the table
const [rows] = await bigqueryClient
.dataset(datasetId)
.table(tableId)
.getRows(options)
resolve(rows) //This still has 14000+ rows.
}
browseRows();
});
return promise;
});
【问题讨论】:
标签: javascript node.js firebase google-bigquery