1
2
不能在应用程序引擎数据存储中使属性唯一。相反,您可以为您的模型指定一个保证是唯一的键名-请参见 the docs 详情。 |
2
2
我也遇到了同样的问题,并提出了以下最简单的答案:
重要的是,我首先要检查是否要加载现有实体。 对于完整的解决方案: http://nicholaslemay.blogspot.com/2010/07/app-engine-unique-constraint.html |
3
1
您可以尝试获取实体并对其进行编辑,如果找不到,请创建一个新实体:
这样,当找不到新条目时,它将插入新条目;如果找到新条目,它将使用您所做的更改更新现有条目(参见文档 here ) |
4
1
另一种解决方案是创建一个模型来存储唯一的值,并使用
http://squeeville.com/2009/01/30/add-a-unique-constraint-to-google-app-engine/ |
5
0
我同意尼克的看法。但是,如果您确实希望基于属性检查模型/实体的存在,那么get()方法很方便:
|
6
0
我写了一些代码来做这个。它的想法是非常容易使用。所以你可以这样做:
这就是密码。有很多评论,但实际上只有几行:
|
Noah Watkins · ndb的控制索引。Expando模型属性 6 年前 |
mooose · 如何使用服务帐户从应用程序脚本访问云数据存储 6 年前 |
user2302244 · 从云存储读取大型文件并写入数据存储 6 年前 |