Javascript 如何在onUpdate事件时在大查询中更新数据
我正在将数据从firebase导入到大查询,它在onWrite事件中运行良好,并使用了table.insert函数。 现在我想根据onUpdate事件在大查询中更新数据,但table.update函数不可用且不起作用。建议其他方法。 下面是我的代码Javascript 如何在onUpdate事件时在大查询中更新数据,javascript,firebase,google-bigquery,Javascript,Firebase,Google Bigquery,我正在将数据从firebase导入到大查询,它在onWrite事件中运行良好,并使用了table.insert函数。 现在我想根据onUpdate事件在大查询中更新数据,但table.update函数不可用且不起作用。建议其他方法。 下面是我的代码 exports.updatetobigquery = functions.database.ref('/mn_users/{userId}/').onUpdate(event => { const dataset = bigquery.
exports.updatetobigquery =
functions.database.ref('/mn_users/{userId}/').onUpdate(event => {
const dataset =
bigquery.dataset('KHUSHUApp');//functions.config().bigquery.datasetname);
const table =
dataset.table('mn_users');//functions.config().bigquery.tablename);
console.log('Uppercasing', event.data.val());
return table.update({
'id': event.data.key,
'name': event.data.val().name,
'email': event.data.val().email
});
});
处理此问题的最佳方法:
- BigQuery具有更新数据的能力,但BigQuery是一个分析数据库,而不是为更新而优化的数据库
- 因此,如果您有其他实现目标的方法,请避免在BigQuery中更新数据
- 在以后分析时,将新行发送到BigQuery-消除重复并合并最新值,而不是更新。当您需要能够在每次状态更改时返回并分析该状态时,此模式非常有用