Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions lib/bigquery/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
33 changes: 4 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,42 +1,17 @@
{
"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/",
"AUTHORS",
"CONTRIBUTORS",
"COPYING"
],
"repository": "googlecloudplatform/gcloud-node",
"repository": "dynamic-email/gcloud-node",
"keywords": [
"google apis client",
"google api client",
Expand Down