Skip to content

Commit

Permalink
Changes for Datastore v1beta3.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmdobry committed Mar 1, 2016
1 parent d72e429 commit 91badac
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
31 changes: 26 additions & 5 deletions datastore/concepts.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function Entity(projectId) {
if (keyFile) {
options.keyFilename = keyFile;
}
this.datastore = gcloud.datastore.dataset(options);
this.datastore = gcloud.datastore(options);

// To create the keys, we have to use this instance of Datastore.
datastore.key = this.datastore.key;
Expand Down Expand Up @@ -231,6 +231,27 @@ Entity.prototype.testUpsert = function(callback) {
}, callback);
};

Entity.prototype.testUpsert = function(callback) {
var taskKey = this.getIncompleteKey();
var task = this.getTask();

// [START upsert]
datastore.upsert({
key: taskKey,
data: task
}, function(err) {
if (!err) {
// Task inserted successfully.
}
});
// [END upsert]

this.datastore.upsert({
key: taskKey,
data: task
}, callback);
};

Entity.prototype.testInsert = function(callback) {
var taskKey = this.getIncompleteKey();
var task = this.getTask();
Expand Down Expand Up @@ -444,7 +465,7 @@ function Index(projectId) {
if (keyFile) {
options.keyFilename = keyFile;
}
this.datastore = gcloud.datastore.dataset(options);
this.datastore = gcloud.datastore(options);
}

Index.prototype.testUnindexedPropertyQuery = function(callback) {
Expand Down Expand Up @@ -494,7 +515,7 @@ function Metadata(projectId) {
if (keyFile) {
options.keyFilename = keyFile;
}
this.datastore = gcloud.datastore.dataset(options);
this.datastore = gcloud.datastore(options);
}

Metadata.prototype.testNamespaceRunQuery = function(callback) {
Expand Down Expand Up @@ -632,7 +653,7 @@ function Query(projectId) {
if (keyFile) {
options.keyFilename = keyFile;
}
this.datastore = gcloud.datastore.dataset(options);
this.datastore = gcloud.datastore(options);

this.basicQuery = this.getBasicQuery();
this.projectionQuery = this.getProjectionQuery();
Expand Down Expand Up @@ -1067,7 +1088,7 @@ function Transaction(projectId) {
if (keyFile) {
options.keyFilename = keyFile;
}
this.datastore = gcloud.datastore.dataset(options);
this.datastore = gcloud.datastore(options);

this.fromKey = this.datastore.key(['Bank', 1, 'Account', 1]);
this.toKey = this.datastore.key(['Bank', 1, 'Account', 2]);
Expand Down
2 changes: 1 addition & 1 deletion datastore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
},
"dependencies": {
"async": "^1.5.2",
"gcloud": "^0.28.0"
"gcloud": "stephenplusplus/gcloud-node#spp--datastore-v1beta3"
}
}
6 changes: 6 additions & 0 deletions test/datastore/entity.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ describe('datastore/concepts/entity', function () {
});
});

describe('testUpsert', function() {
it('saves with an upsert', function(done) {
entity.testUpsert(done);
});
});

describe('testInsert', function() {
it('saves with an insert', function(done) {
entity.testInsert(done);
Expand Down

0 comments on commit 91badac

Please sign in to comment.