duanmie9682 2012-10-20 21:49 采纳率: 100%
浏览 46

Golang GAE-在数据存储区的结构中更改变量名称

I am programming a Google Apps Engine Go application and I would like to change a variable name inside a structure that is stored in the datastore.

Say I have a struct:

type AA struct{
    A string
    BB string
}

And would like to change BB into B. If I try just changing BB into B, the datastore will start giving me errors when it would try to assign stored BB values to new struct AA that does not have that variable. I can add B and still keep BB, but then the struct would start getting messy.

How can I neatly change variable structure in GAE Go datastore without resorting to temporary copying over the entire database and wiping a lot of data?

  • 写回答

2条回答 默认 最新

  • dousi8237 2012-10-21 03:24
    关注

    You can have your AA implement PropertyLoadSaver as described in the Datastore docs, an then

    1. in Load method copy BB into B
    2. in Save method just save A and B
    评论

报告相同问题?

悬赏问题

  • ¥15 opencv图像处理,需要四个处理结果图
  • ¥15 无线移动边缘计算系统中的系统模型
  • ¥15 深度学习中的画图问题
  • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条
  • ¥15 Python报错怎么解决
  • ¥15 simulink如何调用DLL文件
  • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离
  • ¥30 线性代数的问题,我真的忘了线代的知识了
  • ¥15 有谁能够把华为matebook e 高通骁龙850刷成安卓系统,或者安装安卓系统
  • ¥188 需要修改一个工具,懂得汇编的人来。