Skip to content

Commit

Permalink
Merge pull request #20 from silvolu/master
Browse files Browse the repository at this point in the history
Change mutation from update to upsert
  • Loading branch information
Burcu Dogan committed Jul 16, 2014
2 parents 4dd4087 + 0afe6fd commit 4f6ee73
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/datastore/entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ module.exports.keyFromKeyProto = keyFromKeyProto;

var keyToKeyProto = function(datasetId, key) {
if (key.length < 2) {
throw new Error("A key should contain at least a kind and an idenfier.")
throw new Error("A key should contain at least a kind and an identifier.")
}
var namespace = null, start = 0;
if (key.length % 2 == 1) {
Expand Down
4 changes: 2 additions & 2 deletions lib/datastore/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ Transaction.prototype.saveAll = function(keys, objs, callback) {
var req = {
mode: MODE_NON_TRANSACTIONAL,
mutation: {
update: [],
upsert: [],
insertAutoId: []
}
};
Expand All @@ -184,7 +184,7 @@ Transaction.prototype.saveAll = function(keys, objs, callback) {
var e = entity.entityToEntityProto(objs[i]);
e.key = entity.keyToKeyProto(this.id, keys[i]);
if (entity.isKeyComplete(keys[i])) {
req.mutation.update.push(e);
req.mutation.upsert.push(e);
} else {
insertIndexes.push(i);
req.mutation.insertAutoId.push(e);
Expand Down
4 changes: 2 additions & 2 deletions test/datastore.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ describe('Dataset', function() {
var ds = new datastore.Dataset({ projectId: 'test' });
ds.transaction.makeReq = function(method, proto, callback) {
assert.equal(method, 'commit');
assert.equal(proto.mutation.update.length, 2);
assert.equal(proto.mutation.update[0].properties.k.stringValue, 'v');
assert.equal(proto.mutation.upsert.length, 2);
assert.equal(proto.mutation.upsert[0].properties.k.stringValue, 'v');
callback();
};
ds.saveAll([
Expand Down

0 comments on commit 4f6ee73

Please sign in to comment.