2012-06-09 90 views

回答

1

您最好的辦法可能是將該屬性另存爲一個空白字符串,用於每個對該屬性具有空值的實體。一定要在你改變的每個實體上運行put()。

employees = Employee.all().fetch(50) 
for employee in employees: 
    if employee.hobbies is None: # Null value property 
     employee.hobbies = "" 
     employee.put() 

當然,這不是執行此任務的最有效方式。您可能希望創建一個列表對象,如「batch_put_list」,並將每個員工對象附加到列表中。然後,執行db.put(batch_put_list)。

batch_put_list = [] 
employees = Employee.all().fetch(50) 
for employee in employees: 
    if employee.hobbies is None: 
     employee.hobbies = "" 
     batch_put_list.append(employee) 
db.put(batch_put_list) 

希望這會有所幫助。