BigQuery:使用nodejs删除和更新行的问题

时间:2018-10-05 19:33:47

标签: node.js google-bigquery

我找到了许多node.js示例来查询数据并将数据插入BigQuery,但是没有找到任何示例以及关于如何删除和更新数据库中行的API描述。我知道这些限制(自上次更改以来30分钟等)。

我从vscode那里得到的唯一提示

bigQuery.dataset(dataset).table(table).deleteFromBigQuery('noIdea') 

但是即使是vscode也无法给我有关更新的提示。

您知道有关此的任何nodejs文档吗?

我一直在寻找的一些资源 query examples by googleapisDMLs google Manual

1 个答案:

答案 0 :(得分:3)

sync_query example为基础:

async function runDeleteQuery(projectId) {
  // Imports the Google Cloud client library
  const BigQuery = require('@google-cloud/bigquery');

  /**
   * TODO(developer): Uncomment the following line before running the sample.
   */
  // const projectId = "your-project-id";

  // Modify this query however you need
  const sqlQuery = "DELETE FROM dataset.table WHERE condition;";

  // Creates a client
  const bigquery = new BigQuery({projectId});

  // Query options list: https://cloud.google.com/bigquery/docs/reference/v2/jobs/query
  const options = {
    query: sqlQuery,
    timeoutMs: 100000, // Time out after 100 seconds.
    useLegacySql: false, // Use standard SQL syntax for queries.
  };

  // Runs the query
  await bigquery.query(options);
}

另请参阅DELETE statement documentation