Skip to content

Updating single field of a model #1588

@MeLight

Description

@MeLight

I have model with multiple fields. The model in the Python App Engine app looks like this:

class Team(ndb.Model):
  field_a = ndb.StringProperty()
  field_b = ndb.StringProperty()
  field_c = ndb.IntegerProperty()

When running this code from the Node.js part of the app:

var key = ds.key(['Team', team_id]);
    ds.update({
      key: key,
      data: [{name: "field_c", value: new_count, excludeFromIndexes: true}]
    }, function(err) {
      if (!err) {
        // Record saved successfully.
      }
    });

I 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?

Thanks

Metadata

Metadata

Labels

api: datastoreIssues related to the Datastore API.type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions