[英]how to cleanly remove ndb properties
in my app i need to remove a few of my models properties. 在我的应用程序中,我需要删除一些模型属性。
i checked out this link but the first issue is that the properties are on a polymodel
and there is no way im going to switch to an expando
for the time to remove the properties, im not even shure what could happen if i change a polymodel
to an expando
. 我检查了该链接 ,但第一个问题是性能上
polymodel
并没有办法即时通讯没有要切换到expando
的时间,除去性能,即时通讯甚至不舒尔如果我改变会发生什么polymodel
到一个expando
。
so how do i remove properties from existing entities? 那么如何从现有实体中删除属性?
i was thinking to set all StringProperty
to None
and then remove these from the model schema and redeploy. 我正在考虑将所有
StringProperty
设置为None
,然后将它们从模型架构中删除并重新部署。 one of those properties is a BooleanProperty
, i can't set this one to None
right?! 这些属性之一是
BooleanProperty
,我不能将此设置为None
吧? or an ndb.PickleProperty
... how should i remove that? 或
ndb.PickleProperty
...我应如何删除?
does anybody know how to get this done properly? 有人知道如何正确完成此工作吗?
If you want to update all your entities the recommended approach is a map/reduce job that reads and rewrites all entities; 如果要更新所有实体,建议的方法是进行映射/归约作业,以读取和重写所有实体。 however it may not be worth it, depending on how much data you have -- the map/reduce isn't free either.
但是,这可能不值得,具体取决于您拥有的数据量-映射/缩小也不是免费的。
Also be sure you test the map/reduce job on a small subset of the data. 另外,请确保您在一小部分数据上测试映射/归约作业。 It is remarkably subtle to truly remove a property from an entity, even if it's not in the model class any more!
从实体中真正删除属性非常微妙,即使该属性不再位于模型类中也是如此! The best approach may be:
最好的方法可能是:
if 'propname' in ent._properties:
del ent._properties['propname']
ent.put()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.