相关疑难解决方法(0)

正确的方法来迁移NDB模型属性

我目前在NDB中有一个模型,我想更改属性名称而不必触及NBD.假设我有以下内容:

from google.appengine.ext import ndb

class User(ndb.Model):
  company = ndb.KeyProperty(repeated=True)
Run Code Online (Sandbox Code Playgroud)

我想要的是更像这样的东西:

class User(ndb.Model):
  company_   = ndb.KeyProperty(repeated=True)

@property
def company(self):
   return '42'

@company.setter
def company(self, new_company):
    #set company here
Run Code Online (Sandbox Code Playgroud)

这样做有相对无痛的方法吗?我希望使用属性getter/setter,但考虑到当前的实现,我想避免触及底层数据存储.

python google-app-engine app-engine-ndb google-cloud-datastore

3
推荐指数
1
解决办法
408
查看次数