Google app engine 如何从GAE NDB属性中删除值(类型BlobKeyProperty)
这可能是最愚蠢的问题,对此我深表歉意,但我感到困惑 我拥有以下实体:Google app engine 如何从GAE NDB属性中删除值(类型BlobKeyProperty),google-app-engine,python-2.7,app-engine-ndb,Google App Engine,Python 2.7,App Engine Ndb,这可能是最愚蠢的问题,对此我深表歉意,但我感到困惑 我拥有以下实体: class Profile(ndb.Model): name = ndb.StringProperty() identifier = ndb.StringProperty() pic = ndb.BlobKeyProperty() # stores the key to the profile picture blob 我想删除上述实体的“pic”属性值,使其看起来像从未为“pic”赋值
class Profile(ndb.Model):
name = ndb.StringProperty()
identifier = ndb.StringProperty()
pic = ndb.BlobKeyProperty() # stores the key to the profile picture blob
我想删除上述实体的“pic”属性值,使其看起来像从未为“pic”赋值一样新鲜。我不打算删除完整的实体。以下方法是否正确:
qry = Profile.query(Profile.identifier==identifier)
result_record_list = qry.fetch()
if result_record_list:
result_record_list[0].pic.delete() # or result_record_list[0].pic = none # or undefined or null
我正在删除此blob键单独引用的实际blob为其分配None并将其放回数据存储
result_record_list[0].pic = None
result_record_list[0].put()
为其分配None并将其放回数据存储
result_record_list[0].pic = None
result_record_list[0].put()
数据存储是一个OO无模式数据库。因此,您可以在不需要模式更新的情况下从类(ndb.Model)中添加和删除属性
如果您还想清理实体,请查看数据存储是一个OO无模式数据库。因此,您可以在不需要模式更新的情况下从类(ndb.Model)中添加和删除属性
如果您还想清理实体,请查看感谢voscausa的回复Tanks voscausa的回复Tanks omair_77的回复Tanks omair_77的回复