1
這裏是StructuredProperty from the docs一個例子:如何檢索和操作ndb StructuredProperty對象?
class Address(ndb.Model):
type = ndb.StringProperty() # E.g., 'home', 'work'
street = ndb.StringProperty()
city = ndb.StringProperty()
class Contact(ndb.Model):
name = ndb.StringProperty()
addresses = ndb.StructuredProperty(Address, repeated=True)
guido = Contact(name='Guido',
addresses=[Address(type='home',
city='Amsterdam'),
Address(type='work',
street='Spear St',
city='SF')])
guido.put()
試想,圭多暫時在城市廷巴克圖,馬裏的工作。我將如何去檢索和更新他的工作地址?
謝謝。
謝謝,@Hans然後。你錯過了一個冒號,但是否則代碼工作:) –
修正了冒號:-) –