Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/357.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python NDB/Google应用程序引擎中的外键_Python_Google App Engine - Fatal编程技术网

Python NDB/Google应用程序引擎中的外键

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

我正在使用Google应用程序引擎中的NDB构建一个带有Google端点和数据存储的web应用程序。每个登录的用户都有一组“关注列表”,这只是NDB expando模型中的重复属性,如下所示:

类用户(ndb.Expando):

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()?

我尝试过这个功能。看起来您可以使用以下方法完成此工作: