From 578c64d2dcb5e7913446124c05d591ed65e19ef4 Mon Sep 17 00:00:00 2001 From: Burcu Dogan Date: Fri, 11 Jul 2014 14:36:45 -0700 Subject: [PATCH] datastore: return a mix of auto-inserted and already existing keys. fixes #17. --- lib/datastore/index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/datastore/index.js b/lib/datastore/index.js index 68c21e6b6d7..906f1958b45 100644 --- a/lib/datastore/index.js +++ b/lib/datastore/index.js @@ -195,9 +195,10 @@ Transaction.prototype.saveAll = function(keys, objs, callback) { if (err || !resp) { return callback(err); } - var keys = []; - resp.mutationResult.insertAutoIdKeys && resp.mutationResult.insertAutoIdKeys.forEach(function(item) { - keys.push(entity.keyFromKeyProto(item)); + resp.mutationResult.insertAutoIdKeys = resp.mutationResult.insertAutoIdKeys || []; + var i = 0; + resp.mutationResult.insertAutoIdKeys.forEach(function(item) { + keys[insertIndexes[i++]] = entity.keyFromKeyProto(item); }); callback(null, keys); });