更新实体的属性而不从NDB中检索实体

问题描述:

我想更新一个拥有很多属性的实体的属性。

I would like to update a property of an entity that has a lot of properties.

如果我正确地理解它,每当我从数据存储中检索实体时,

If I understand it correctly, whenever I retrieve the entity from the datastore by

entity = key_of_entity.get()

稍后更新它的属性

entity.some_property += 1
entity.put()

我需要阅读该实体的每个属性?由于这个实体具有不少属性,所以这样的阅读一遍又一遍可能是相当昂贵的。有没有办法更新一个实体的属性,而不必先读它?

I am charged for read of every property of that entity? Since this entity has quite a few properties, such reading over and over again can be quite expensive. Is there any way to update an entity's property without having to do a read on it first?

唯一的解决方案是将此实体分为两部分:很少更新并经常更新。你可以让它们完全独立(一个实体的ID作为另一个实体的属性),或者你可以让它们中的一个成为父母,另一个成为孩子。

The only solution is to split this entity into two parts: rarely updated and frequently updated. You can make them totally independent (with an id of one entity as a property in another entity), or you can make one of them a parent and the other one a child.