2014-02-24 90 views
1

这可能是最愚蠢的问题和我的一样道歉,但我很困惑如何从GAE NDB属性(类型BlobKeyProperty)删除值

我有以下实体:

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分别

回答

3

分配无,并把它回数据存储区。

result_record_list[0].pic = None 
result_record_list[0].put() 
+0

感谢omair_77您的回复 – gsinha

1

该数据存储区是一个OO无模式数据库。因此,您可以添加和删除Kind(ndb.Model)中的属性,而无需模式更新。

如果您还想要清除的实体看this anwser from Guido

+0

感谢voscausa您的回复 – gsinha