Python NDB:查询未设置的属性?
我在几天的生产过程中收集了一些数据,比如说,使用以下模型:Python NDB:查询未设置的属性?,python,google-app-engine,google-cloud-datastore,app-engine-ndb,Python,Google App Engine,Google Cloud Datastore,App Engine Ndb,我在几天的生产过程中收集了一些数据,比如说,使用以下模型: class Tags(ndb.Model): dt_added = ndb.DateTimeProperty(auto_now_add=True) s_name = ndb.StringProperty(required=True, indexed=True) 假设我现在向模型添加了一个新属性: class Foo(ndb.Model): is_valid = ndb.BooleanProperty(def
class Tags(ndb.Model):
dt_added = ndb.DateTimeProperty(auto_now_add=True)
s_name = ndb.StringProperty(required=True, indexed=True)
假设我现在向模型添加了一个新属性:
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)
。。。用这个新模型收集更多的数据
所以现在我有一部分数据设置了属性new_prop
,另一部分没有设置
我的问题是:如何查询未设置新属性的数据
我试过:
query_tags = Tags.query(Tags.new_prop == None).fetch()
但如果没有属性集,似乎无法获取数据。。。有什么建议吗?
谢谢 数据存储区区分不具有属性的实体和具有空值(无)属性的实体 无法查询特定缺少给定属性的实体。另一种方法是定义一个默认值为“无”的固定(建模)特性,然后筛选该特性值为“无”的实体