Reputation: 509
I'm trying to get some data from a BigQuery table into my React front end using a firebase cloud function.
My table has 14000+ rows, so I don't want to bring them all in at the same time, I'd prefer to send a request to get 100 or so at a time.
I've looked at the documentation here: https://cloud.google.com/bigquery/docs/managing-table-data#browse-table
But their solutions don't seem to be having any impact on what gets returned.
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;
});
Upvotes: 1
Views: 422
Reputation: 59245
I'm not sure what library you're using, but if it's this one, then the name of the option is maxResults
, not limit
.
Upvotes: 2