I have a fairly simple ndb model that already exists has had instances created in the datastore. It looks something like this:
class ExampleModel(ndb.Model):
property1 = ndb.StringProperty()
property2 = ndb.StringProperty()
I want to add a created
property to it, so that I can sort them by the time they were created.
class ExampleModel(ndb.Model):
property1 = ndb.StringProperty()
property2 = ndb.StringProperty()
created = ndb.DateTimeProperty(auto_now_add=True)
When I do this, and try to query for the list of entities ordered by created
, it only returns entities that have been created after updating the model definition.
things = ExampleModel.query().order(ExampleModel.created).fetch()
I have tried adding a default value to created
, set to the epoch which is where I would like existing entities to be in the ordered list, but they still are not included in that ordered query. Is there any way to include them, or do I need to migrate the existing entities and set their created
property explicitly?