Skip to content

Commit 4f6ee73

Browse files
author
Burcu Dogan
committed
Merge pull request #20 from silvolu/master
Change mutation from update to upsert
2 parents 4dd4087 + 0afe6fd commit 4f6ee73

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

lib/datastore/entity.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ module.exports.keyFromKeyProto = keyFromKeyProto;
7676

7777
var keyToKeyProto = function(datasetId, key) {
7878
if (key.length < 2) {
79-
throw new Error("A key should contain at least a kind and an idenfier.")
79+
throw new Error("A key should contain at least a kind and an identifier.")
8080
}
8181
var namespace = null, start = 0;
8282
if (key.length % 2 == 1) {

lib/datastore/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ Transaction.prototype.saveAll = function(keys, objs, callback) {
172172
var req = {
173173
mode: MODE_NON_TRANSACTIONAL,
174174
mutation: {
175-
update: [],
175+
upsert: [],
176176
insertAutoId: []
177177
}
178178
};
@@ -184,7 +184,7 @@ Transaction.prototype.saveAll = function(keys, objs, callback) {
184184
var e = entity.entityToEntityProto(objs[i]);
185185
e.key = entity.keyToKeyProto(this.id, keys[i]);
186186
if (entity.isKeyComplete(keys[i])) {
187-
req.mutation.update.push(e);
187+
req.mutation.upsert.push(e);
188188
} else {
189189
insertIndexes.push(i);
190190
req.mutation.insertAutoId.push(e);

test/datastore.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ describe('Dataset', function() {
163163
var ds = new datastore.Dataset({ projectId: 'test' });
164164
ds.transaction.makeReq = function(method, proto, callback) {
165165
assert.equal(method, 'commit');
166-
assert.equal(proto.mutation.update.length, 2);
167-
assert.equal(proto.mutation.update[0].properties.k.stringValue, 'v');
166+
assert.equal(proto.mutation.upsert.length, 2);
167+
assert.equal(proto.mutation.upsert[0].properties.k.stringValue, 'v');
168168
callback();
169169
};
170170
ds.saveAll([

0 commit comments

Comments
 (0)