如何按名称查询Google App Engine实体以转换为新名称? [英] How can I query Google App Engine entities by name to convert to new names?
问题描述
我想将一些实体转换为新名称。我如何查询没有定义模型类的实体。
例如,我有这样的实体(它被简化为更具可读性):
class Some(ndb.model):
name = ndb.StringProperty()
我想将它重命名为:
class SomeFile(ndb.model ):
name = ndb.StringProperty()
我该怎么做?
如果将某些
重命名为 SomeFile
,则不会再有一些
查询数据存储区中的数据。 您可以更改通过重写模型的 _get_kind()
方法来指定模型类名称,并使其指向现有数据存储 Kind
p>
class SomeFile(ndb.Model):
@classmethod
def _get_kind(cls):
return'Some'
现在您可以使用 SomeFile
在第页ython代码,同时在数据存储中保留一些
实体。
$ b
https://cloud.google.com/appengine/docs/python/ndb/modelclass#introduction
I want to convert some Entities to new names. How can I query entities not having model class defined.
For example I have such entity (it simplified to be more readable):
class Some(ndb.model):
name = ndb.StringProperty()
I want to rename it to:
class SomeFile(ndb.model):
name = ndb.StringProperty()
How can I do it?
If will rename Some
to SomeFile
there will be no more Some
to query but only data in datastore.
You can change your Model class name and have it point to an existing datastore Kind
by overriding the Model's _get_kind()
method.
class SomeFile(ndb.Model):
@classmethod
def _get_kind(cls):
return 'Some'
Now you can use SomeFile
in python code while retaining the Some
entities in your datastore.
https://cloud.google.com/appengine/docs/python/ndb/modelclass#introduction
这篇关于如何按名称查询Google App Engine实体以转换为新名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!