Skip to content

Commit

Permalink
Merge pull request #250 from stephenplusplus/spp--datastore-finalize-…
Browse files Browse the repository at this point in the history
…transactions

datastore: fix - mark transactions as finalized.
  • Loading branch information
silvolu committed Oct 9, 2014
2 parents 5def8e7 + c79a52d commit c528eed
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/datastore/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,15 @@ DatastoreRequest.prototype.save = function(entities, callback) {
callback(err);
return;
}
if (this.id) {
this.isFinalized = true;
}
var autoInserted = (resp.mutation_result.insert_auto_id_key || []);
autoInserted.forEach(function(key, index) {
keys[insertIndexes[index]] = entity.keyFromKeyProto(key);
});
callback(null, isMultipleRequest ? keys : keys[0]);
});
}.bind(this));
};

/**
Expand Down Expand Up @@ -300,7 +303,12 @@ DatastoreRequest.prototype.delete = function(keys, callback) {
}
req = new pb.CommitRequest(req);
var res = pb.CommitResponse;
this.createRequest_('commit', req, res, callback);
this.createRequest_('commit', req, res, function(err) {
if (!err && this.id) {
this.isFinalized = true;
}
callback.apply(null, util.toArray(arguments));
}.bind(this));
};

/**
Expand Down

0 comments on commit c528eed

Please sign in to comment.