Python NDB/Google应用程序引擎中的外键
我正在使用Google应用程序引擎中的NDB构建一个带有Google端点和数据存储的web应用程序。每个登录的用户都有一组“关注列表”,这只是NDB expando模型中的重复属性,如下所示: 类用户(ndb.Expando):Python NDB/Google应用程序引擎中的外键,python,google-app-engine,Python,Google App Engine,我正在使用Google应用程序引擎中的NDB构建一个带有Google端点和数据存储的web应用程序。每个登录的用户都有一组“关注列表”,这只是NDB expando模型中的重复属性,如下所示: 类用户(ndb.Expando): username = ndb.StringProperty() email = ndb.StringProperty() password = ndb.StringProperty() overallRanking = ndb.IntegerProperty() num
username = ndb.StringProperty()
email = ndb.StringProperty()
password = ndb.StringProperty()
overallRanking = ndb.IntegerProperty()
numRankings = ndb.IntegerProperty()
watchedListings = ndb.KeyProperty(modelListing,repeated=True)
如您所见,我正在存储modelListing实体的密钥。但是,当我删除modelListing时,我希望它自动删除在其watchedListings对象中具有该密钥的所有用户的密钥。这类似于SQL处理外键的方式。有没有一种方法可以做到这一点,而不必遍历数据库中的所有用户,搜索该键,删除它,然后执行put()?我尝试过这个功能。看起来您可以使用以下方法完成此工作: