From 0b953f5fae33310ee276486834e113886c356f17 Mon Sep 17 00:00:00 2001 From: Johan Euphrosine Date: Wed, 9 Jul 2014 04:16:09 -0700 Subject: [PATCH] index: guard mutation result auto-insert-id --- lib/datastore/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/datastore/index.js b/lib/datastore/index.js index 84164f196e5..68c21e6b6d7 100644 --- a/lib/datastore/index.js +++ b/lib/datastore/index.js @@ -195,9 +195,9 @@ Transaction.prototype.saveAll = function(keys, objs, callback) { if (err || !resp) { return callback(err); } - var keys = [], i = 0; - resp.mutationResult.insertAutoIdKeys.forEach(function(item) { - keys[i++] = entity.keyFromKeyProto(item); + var keys = []; + resp.mutationResult.insertAutoIdKeys && resp.mutationResult.insertAutoIdKeys.forEach(function(item) { + keys.push(entity.keyFromKeyProto(item)); }); callback(null, keys); });