-
Notifications
You must be signed in to change notification settings - Fork 639
Closed
Labels
api: datastoreIssues related to the Datastore API.Issues related to the Datastore API.
Description
Environment Details
- OS Details - Mac OSX 10.12
- Node version - 4.3.0
- npm version - 3.10.3
- google-cloud/datastore version - 0.5.0
Steps to reproduce
Trying to update an entity in datastore. This documentation says that I should get an entity, make the required changes and then save it back using the save method.
var Datastore = require('@google-cloud/datastore');
//Initialize the Datastore object.
var ds = Datastore({
projectId: 'my-project'
});
//Datastore Key
var key = ds.key({
namespace: 'myNameSpace',
path: ['kind', 'name_of_the_entity']
});
ds.get(key, function(error, entity) {
if(error) {
//Error handler
} else {
//Make changes in entity.
ds.save(entity, function(error) {
if(error) {
//Error handler
} else {
//Entity updated.
}
})
}
});
Stack Trace
/project/node_modules/@google-cloud/datastore/src/entity.js:506
if (!is.string(key.path[0])) {
^
TypeError: Cannot read property 'path' of undefined
at Object.keyToKeyProto (/project/node_modules/@google-cloud/datastore/src/entity.js:506:21)
at Object.isKeyComplete (/project/node_modules/@google-cloud/datastore/src/entity.js:434:32)
at /project/node_modules/@google-cloud/datastore/src/request.js:869:17
at Array.forEach (native)
at DatastoreRequest.save (/project/node_modules/@google-cloud/datastore/src/request.js:854:12)
at Datastore.wrapper [as save] (/project/node_modules/@google-cloud/datastore/node_modules/@google-cloud /common/src/util.js:654:29)
at /project/index.js:72:29
at /project/node_modules/@google-cloud/datastore/src/request.js:417:7
at ConcatStream.<anonymous> (/project/node_modules/@google-cloud/datastore/node_modules/concat-stream/ index.js:36:43)
at emitNone (events.js:72:20)
I would need the save method to work for all the update operations happening across my application
Metadata
Metadata
Assignees
Labels
api: datastoreIssues related to the Datastore API.Issues related to the Datastore API.