我在App Maker应用中创建了一个计算源,该源从Big Query读取数据,效果很好。现在,我想在用户事件上加载数据,因此我编写了一个函数:
function ButtonClick() {
var Objekt = google.script.run.runQuery('Select ... Limit 100;');
return Objekt;
}
function runQuery(Query) {
var projectId = 'en-int-biggi';
var request;
request = {
query: Query,useLegacySql: false};
var queryResults = BigQuery.Jobs.query(request, projectId);
var jobId = queryResults.jobReference.jobId;
var names = queryResults.schema.fields.map(function(field){ return field.name; });
return queryResults.rows.map(function(row) {
//App Maker doesn't allow to return arbitrary objects through its datasources. All results should be strongly typed:
var record = app.models.Firma.newRecord();
for (var i = 0, len = names.length; i < len; ++i) {
// Calculated model should contain correspondent fields
// all non-defined fields will be ignored
record[names[i]] = (row.f[i].v);
}
console.log(record);
return record;
});
}
通过Button Click调用该函数会出现错误:
返回的日志由于其长度而被删节。 周期性对象无法处理。