【问题标题】:Issue with adding new properties to existing Google AppEngine data models / entities向现有 Google AppEngine 数据模型/实体添加新属性的问题
【发布时间】:2010-10-28 12:10:36
【问题描述】:

在 GAE 中,我有一个名为 Foo 的模型,其中包含现有实体,并尝试向 Foo 添加一个名为 memcached 的新属性,该属性获取最后一次将此值设置为 memcache 的日期时间值。如果我尝试对该属性进行查询和排序,甚至筛选出没有 memcached 值的实体,则不会返回尚未为此属性设置值的实体。我在这里缺少什么,或者作为替代方案,是否有一种快速的方法可以为给定模型的每个实体上的 new 属性设置一个值?

我创建了一堆以下模型的实体,

class Foo(db.Model):
    name = db.StringProperty(required=True)

然后给这个模型添加一个属性,

class Foo(db.Model):
    name = db.StringProperty(required=True)
    memcached = db.DateTimeProperty(required=True, auto_now=True, auto_now_add=True, default=datetime.min)

当我对查询进行排序或过滤时,不考虑新属性的默认值。

【问题讨论】:

    标签: python google-app-engine properties bigtable


    【解决方案1】:

    除了遍历每个现有实体并添加属性here is the official documentation which walks you through the process,别无他法。

    【讨论】:

      猜你喜欢
      • 2015-06-17
      • 2016-01-12
      • 2012-02-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多