Skip to content

Commit f1e4f5e

Browse files
committed
Changes for Datastore v1beta3.
1 parent daa12aa commit f1e4f5e

File tree

3 files changed

+33
-6
lines changed

3 files changed

+33
-6
lines changed

datastore/concepts.js

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function Entity(projectId) {
4747
if (keyFile) {
4848
options.keyFilename = keyFile;
4949
}
50-
this.datastore = gcloud.datastore.dataset(options);
50+
this.datastore = gcloud.datastore(options);
5151

5252
// To create the keys, we have to use this instance of Datastore.
5353
datastore.key = this.datastore.key;
@@ -210,6 +210,27 @@ Entity.prototype.testBasicEntity = function(callback) {
210210
}, callback);
211211
};
212212

213+
Entity.prototype.testUpsert = function(callback) {
214+
var taskKey = this.getIncompleteKey();
215+
var task = this.getTask();
216+
217+
// [START upsert]
218+
datastore.upsert({
219+
key: taskKey,
220+
data: task
221+
}, function(err) {
222+
if (!err) {
223+
// Task inserted successfully.
224+
}
225+
});
226+
// [END upsert]
227+
228+
this.datastore.upsert({
229+
key: taskKey,
230+
data: task
231+
}, callback);
232+
};
233+
213234
Entity.prototype.testInsert = function(callback) {
214235
var taskKey = this.getIncompleteKey();
215236
var task = this.getTask();
@@ -423,7 +444,7 @@ function Index(projectId) {
423444
if (keyFile) {
424445
options.keyFilename = keyFile;
425446
}
426-
this.datastore = gcloud.datastore.dataset(options);
447+
this.datastore = gcloud.datastore(options);
427448
}
428449

429450
Index.prototype.testUnindexedPropertyQuery = function(callback) {
@@ -473,7 +494,7 @@ function Metadata(projectId) {
473494
if (keyFile) {
474495
options.keyFilename = keyFile;
475496
}
476-
this.datastore = gcloud.datastore.dataset(options);
497+
this.datastore = gcloud.datastore(options);
477498
}
478499

479500
Metadata.prototype.testNamespaceRunQuery = function(callback) {
@@ -611,7 +632,7 @@ function Query(projectId) {
611632
if (keyFile) {
612633
options.keyFilename = keyFile;
613634
}
614-
this.datastore = gcloud.datastore.dataset(options);
635+
this.datastore = gcloud.datastore(options);
615636

616637
this.basicQuery = this.getBasicQuery();
617638
this.projectionQuery = this.getProjectionQuery();
@@ -1046,7 +1067,7 @@ function Transaction(projectId) {
10461067
if (keyFile) {
10471068
options.keyFilename = keyFile;
10481069
}
1049-
this.datastore = gcloud.datastore.dataset(options);
1070+
this.datastore = gcloud.datastore(options);
10501071

10511072
this.fromKey = this.datastore.key(['Bank', 1, 'Account', 1]);
10521073
this.toKey = this.datastore.key(['Bank', 1, 'Account', 2]);

datastore/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
},
1515
"dependencies": {
1616
"async": "^1.5.2",
17-
"gcloud": "^0.28.0"
17+
"gcloud": "stephenplusplus/gcloud-node#spp--datastore-v1beta3"
1818
}
1919
}

test/datastore/entity.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ describe('datastore/concepts/entity', function () {
7979
});
8080
});
8181

82+
describe('testUpsert', function() {
83+
it('saves with an upsert', function(done) {
84+
entity.testUpsert(done);
85+
});
86+
});
87+
8288
describe('testInsert', function() {
8389
it('saves with an insert', function(done) {
8490
entity.testInsert(done);

0 commit comments

Comments
 (0)