diff --git a/lib/bigquery/table.js b/lib/bigquery/table.js index 6bf1213e3e2..adc518ee69f 100644 --- a/lib/bigquery/table.js +++ b/lib/bigquery/table.js @@ -838,7 +838,46 @@ Table.prototype.import = function(source, metadata, callback) { callback(null, job, resp); }); }; +Table.prototype.insertAll = function(rows, callback) { + var body = { + rows: arrify(rows).map(function(row) { + var rowObject = {}; + // Use the stringified contents of the row as a unique insert ID. + var md5 = crypto.createHash('md5'); + md5.update(JSON.stringify(row)); + //rowObject.insertId = md5.digest('hex'); + rowObject.json = row; + return rowObject; + }) + }; + + + this.request({ + method: 'POST', + uri: '/insertAll', + json: body + }, function(err, resp) { + if (err) { + callback(err, null, resp); + return; + } + + var failedToInsert = (resp.insertErrors || []).map(function(insertError) { + return { + errors: insertError.errors.map(function(error) { + return { + message: error.message, + reason: error.reason + }; + }), + row: body.rows[insertError.index].json + }; + }); + + callback(null, failedToInsert, resp); + }); +}; /** * Stream data into BigQuery one record at a time without running a load job. * diff --git a/package.json b/package.json index 0b4c343f9bd..47600e3aaec 100644 --- a/package.json +++ b/package.json @@ -1,34 +1,9 @@ { - "name": "gcloud", - "version": "0.27.0", + "name": "dynamic-gcloud", + "version": "0.27.1", "author": "Google Inc.", "description": "Google Cloud APIs Client Library for Node.js", - "contributors": [ - { - "name": "Burcu Dogan", - "email": "jbd@google.com" - }, - { - "name": "Johan Euphrosine", - "email": "proppy@google.com" - }, - { - "name": "Patrick Costello", - "email": "pcostell@google.com" - }, - { - "name": "Ryan Seys", - "email": "ryan@ryanseys.com" - }, - { - "name": "Silvano Luciani", - "email": "silvano@google.com" - }, - { - "name": "Stephen Sawchuk", - "email": "sawchuk@gmail.com" - } - ], + "main": "./lib/index", "files": [ "lib/", @@ -36,7 +11,7 @@ "CONTRIBUTORS", "COPYING" ], - "repository": "googlecloudplatform/gcloud-node", + "repository": "dynamic-email/gcloud-node", "keywords": [ "google apis client", "google api client",