Skip to content

How to modify entity preserving indexed/unindexed properties? #914

Closed
@vladimirkiva

Description

@vladimirkiva

Getting the provided sample code for nodejs:

  • I'm trying to modify only one property ('done') of the entity Task in sample code tasks.markdone.js
  • What code you've already tried: tasks.add.js and tasks.markdone.js
  • Any error messages you're getting: no

I'm expecting the code in tasks.markdone.js should modify only one property -- done. But it actually modifies two properties: done (as expected) and description. Initially, description property in not indexed as it is created in tasks.add.js. But tasks.markdone.js makes it indexed, that is not expected and undesired.

For this particular case it's easy to fix:

transaction.save({
    key: taskKey,
    data: task,
    excludeFromIndexes: [
        "description"
    ]
});

But in real life fields that are excluded from indexes might be dynamic, so

The question is: What is the best way to get an entity preserving all it's indexed/unindexed fields, modify just one field and save it in the way not to change not touched indexes?

Metadata

Metadata

Assignees

No one assigned

    Labels

    api: datastoreIssues related to the googleapis/nodejs-datastore API.priority: p3Desirable enhancement or fix. May not be included in next release.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