2014-02-24 93 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