在不从 NDB 检索实体的情况下更新实体的属性 [英] updating an entity's property without retrieving the entity from the NDB

查看:32
本文介绍了在不从 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.

这篇关于在不从 NDB 检索实体的情况下更新实体的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆