{"action":"created","issue":{"url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-node/issues/1588","repository_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-node","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-node/issues/1588/labels{/name}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-node/issues/1588/comments","events_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-node/issues/1588/events","html_url":"https://github.com/GoogleCloudPlatform/google-cloud-node/issues/1588","id":176115970,"number":1588,"title":"Updating single field of a model","user":{"login":"MeLight","id":704484,"avatar_url":"https://avatars.githubusercontent.com/u/704484?v=3","gravatar_id":"","url":"https://api.github.com/users/MeLight","html_url":"https://github.com/MeLight","followers_url":"https://api.github.com/users/MeLight/followers","following_url":"https://api.github.com/users/MeLight/following{/other_user}","gists_url":"https://api.github.com/users/MeLight/gists{/gist_id}","starred_url":"https://api.github.com/users/MeLight/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MeLight/subscriptions","organizations_url":"https://api.github.com/users/MeLight/orgs","repos_url":"https://api.github.com/users/MeLight/repos","events_url":"https://api.github.com/users/MeLight/events{/privacy}","received_events_url":"https://api.github.com/users/MeLight/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-node/labels/datastore","name":"datastore","color":"0052cc"},{"url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-node/labels/question","name":"question","color":"cc317c"}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-09-09T21:30:46Z","updated_at":"2016-09-12T11:16:01Z","closed_at":"2016-09-12T11:16:01Z","body":"I have model with multiple fields. The model in the Python App Engine app looks like this:\r\n```\r\nclass Team(ndb.Model):\r\n  field_a = ndb.StringProperty()\r\n  field_b = ndb.StringProperty()\r\n  field_c = ndb.IntegerProperty()\r\n```\r\n\r\nWhen running this code from the Node.js part of the app:\r\n```js\r\nvar key = ds.key(['Team', team_id]);\r\n    ds.update({\r\n      key: key,\r\n      data: [{name: \"field_c\", value: new_count, excludeFromIndexes: true}]\r\n    }, function(err) {\r\n      if (!err) {\r\n        // Record saved successfully.\r\n      }\r\n    });\r\n\r\n```\r\n\r\nI get fields `field_a` and `field_b` **deleted** from the model. How can I update only one field of the object without deleting the other fields?\r\n\r\nThanks"},"comment":{"url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-node/issues/comments/246317803","html_url":"https://github.com/GoogleCloudPlatform/google-cloud-node/issues/1588#issuecomment-246317803","issue_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-node/issues/1588","id":246317803,"user":{"login":"stephenplusplus","id":723048,"avatar_url":"https://avatars.githubusercontent.com/u/723048?v=3","gravatar_id":"","url":"https://api.github.com/users/stephenplusplus","html_url":"https://github.com/stephenplusplus","followers_url":"https://api.github.com/users/stephenplusplus/followers","following_url":"https://api.github.com/users/stephenplusplus/following{/other_user}","gists_url":"https://api.github.com/users/stephenplusplus/gists{/gist_id}","starred_url":"https://api.github.com/users/stephenplusplus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stephenplusplus/subscriptions","organizations_url":"https://api.github.com/users/stephenplusplus/orgs","repos_url":"https://api.github.com/users/stephenplusplus/repos","events_url":"https://api.github.com/users/stephenplusplus/events{/privacy}","received_events_url":"https://api.github.com/users/stephenplusplus/received_events","type":"User","site_admin":false},"created_at":"2016-09-12T11:16:01Z","updated_at":"2016-09-12T11:16:01Z","body":"You have to do a manual \"get and update\", which would look like:\r\n\r\n```js\r\nvar key = ds.key(['Team', team_id]);\r\n\r\nds.get(key, function(err, entity) {\r\n  if (err) {\r\n    // Error handling omitted.\r\n  }\r\n\r\n  entity.data.field_c = newCount;\r\n\r\n  ds.save({\r\n    key: key,\r\n    data: entity.data\r\n  }, function(err) {\r\n    if (!err) {\r\n      // Record saved successfully.\r\n    }\r\n  });\r\n});\r\n```"}}
{"actor":{"display_login":"stephenplusplus"}}