diff --git a/lib/datastore/index.js b/lib/datastore/index.js index 53ebc0acb1c..5122faf73f2 100644 --- a/lib/datastore/index.js +++ b/lib/datastore/index.js @@ -46,7 +46,7 @@ Transaction.prototype.begin = function(callback) { var that = this; this.makeReq('beginTransaction', null, function(err, resp) { if (!err) { - that.id = resp; + that.id = resp.transaction; } callback && callback(err); }); @@ -69,7 +69,7 @@ Transaction.prototype.rollback = function(callback) { /** * Commit commits the remote transaction and finalizes the - * current transaction insance. + * current transaction instance. */ Transaction.prototype.commit = function(callback) { var that = this; @@ -83,7 +83,7 @@ Transaction.prototype.commit = function(callback) { }; /** - * Finalize commits a transction if it's not finalized yet. + * Finalize commits a transaction if it's not finalized yet. */ Transaction.prototype.finalize = function(callback) { if (!this.isFinalized) { @@ -182,7 +182,7 @@ Transaction.prototype.saveAll = function(keys, objs, callback) { } for (var i = 0; i < keys.length; i++) { var e = entity.entityToEntityProto(objs[i]); - e.key = entity.keyToKeyProto(this.id, keys[i]); + e.key = entity.keyToKeyProto(this.datasetId, keys[i]); if (entity.isKeyComplete(keys[i])) { req.mutation.upsert.push(e); } else { @@ -294,6 +294,8 @@ Transaction.prototype.mapQuery = function(q, mapperFn, opt_callback) { */ Transaction.prototype.makeReq = function(method, req, callback) { // TODO(jbd): Switch to protobuf API. + // Always pass a value for json to automagically get headers/response parsing. + req = req || true; this.conn.req({ method: 'POST', uri: DATASTORE_BASE_URL + '/' + this.datasetId + '/' + method,