在不从 NDB 检索实体的情况下更新实体的属性

编程入门 行业动态 更新时间:2024-10-17 11:25:34
本文介绍了在不从 NDB 检索实体的情况下更新实体的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我想更新具有很多属性的实体的属性.

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屋!

更多推荐

[db:关键词]

本文发布于:2023-04-17 19:25:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/921516.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:实体   不从   属性   情况下   NDB

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!