【发布时间】:2014-07-19 20:25:08
【问题描述】:
我正在使用 Google App Engine 中的 NDB 构建一个带有 Google Endpoints 和 Datastore 的网络应用程序。每个登录的用户都有一组“关注列表”,这只是 NDB 扩展模型中的重复属性,如下所示:
类用户(ndb.Expando):
username = ndb.StringProperty()
email = ndb.StringProperty()
password = ndb.StringProperty()
overallRanking = ndb.IntegerProperty()
numRankings = ndb.IntegerProperty()
watchedListings = ndb.KeyProperty(modelListing,repeated=True)
如您所见,我正在存储模型列表实体的键。但是,当我删除一个 modelListing 时,我希望它自动删除所有在其 watchListings 对象中拥有该键的用户的键。这类似于 SQL 如何处理外键。有没有办法做到这一点,而无需遍历数据库中的所有用户并搜索该密钥、删除它并执行 put()?
【问题讨论】: