You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
/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
The text was updated successfully, but these errors were encountered:
So your example should work with some changes to account for this:
ds.get(key,function(error,entity){if(error){//Error handler}else{//Make changes in entity.ds.save({key: entity[ds.key],data: entity},function(error){if(error){//Error handler}else{//Entity updated.}})}});
Sorry for the confusion. Our docs were left behind in some spots, but I've sent #1725 to correct them. Can you let me know where you found this example in the docs so I can make sure I got it in #1725?
Thank you @stephenplusplus for the prompt reply. The second last code snippet under examples in get method documentation illustrates how to save an entity using the get and the save method.
Ah, ha! Thanks for calling that out. I've sent a PR to fix that, and I believe after that, we'll have them all covered. Sorry again for the inconvenience.
Environment Details
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 thesave
method.Stack Trace
I would need the
save
method to work for all the update operations happening across my applicationThe text was updated successfully, but these errors were encountered: