dynamic-gcloud
Advanced tools
Comparing version 0.27.0 to 0.27.1
@@ -841,3 +841,42 @@ /*! | ||
}; | ||
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); | ||
}); | ||
}; | ||
/** | ||
@@ -844,0 +883,0 @@ * Stream data into BigQuery one record at a time without running a load job. |
{ | ||
"name": "dynamic-gcloud", | ||
"version": "0.27.0", | ||
"version": "0.27.1", | ||
"author": "Google Inc.", | ||
@@ -5,0 +5,0 @@ "description": "Google Cloud APIs Client Library for Node.js", |
690892
20142