ฉันจะสร้างอินสแตนซ์ของเอนทิตีภายในเอนทิตีเดียวกันได้อย่างไร สิ่งที่ฉันต้องการคือ:
class User(ndb.model):
friends = ndb.StructuredProperty( User, repeated=True )
ฉันจะสร้างอินสแตนซ์ของเอนทิตีภายในเอนทิตีเดียวกันได้อย่างไร สิ่งที่ฉันต้องการคือ:
class User(ndb.model):
friends = ndb.StructuredProperty( User, repeated=True )
คุณสามารถอัปเดตโมเดลแบบไดนามิกได้หลังจากที่ถูกสร้างขึ้น:
class User(ndb.Model):
pass
User.friends = ndb.StructuredProperty(User, repeated=True)
User._fix_up_properties()
_fix_up_properties
คำอธิบายจากแหล่งที่มา:
def _fix_up_properties(cls):
"""Fix up the properties by calling their _fix_up() method.
Note: This is called by MetaModel, but may also be called manually
after dynamically updating a model class.
"""