Mic*_*dek 5 python google-app-engine app-engine-ndb google-cloud-datastore
我已经在生产中收集了一些数据,比如说,以下模型:
class Tags(ndb.Model):
dt_added = ndb.DateTimeProperty(auto_now_add=True)
s_name = ndb.StringProperty(required=True, indexed=True)
Run Code Online (Sandbox Code Playgroud)
想象一下,我现在为模型添加一个新属性:
class Foo(ndb.Model):
is_valid = ndb.BooleanProperty(default=False)
some_key = ndb.KeyProperty(repeated=True)
class Tags(ndb.Model):
dt_added = ndb.DateTimeProperty(auto_now_add=True)
name = ndb.StringProperty(required=True, indexed=True)
new_prop = ndb.StructuredProperty(Foo)
Run Code Online (Sandbox Code Playgroud)
...并使用这个新模型收集更多数据.
所以现在我有一部分属性new_prop设置的数据,另一部分没有设置.
我的问题是:如何使用未new_prop设置的新属性查询数据?
我试过了:
query_tags = Tags.query(Tags.new_prop == None).fetch()
Run Code Online (Sandbox Code Playgroud)
但似乎没有设置该属性的数据...任何建议?谢谢!
数据存储区分不具有属性的实体和具有空值的属性(无).
无法查询特定缺少给定属性的实体.另一种方法是使用默认值None定义固定(建模)属性,然后筛选具有None作为该属性值的实体.
| 归档时间: |
|
| 查看次数: |
2298 次 |
| 最近记录: |