google-app-engine - Go App Engine 嵌套对象未存储在 Cloud Datastore 中

标签 google-app-engine go google-cloud-datastore

我有一个 EmergencyCase 实体,它有 2 个嵌入式结构(1 个数组和 1 个结构) 当我尝试通过调用保存 EmergencyCase 时:

datastore.Put(c, key, &ec)

除 Pos 字段(类型 Position)外,所有内容都存储良好。没有关于此的错误或日志条目。它只是没有存储。有什么建议吗?

这是我的 3 个实体定义:

type Position struct{
    lon float32
    lat float32
}
type EmergencyCase struct{
    // Autogenerated id, not stored in the database.
    ID string `datastore:"-"`
    CreatedAt time.Time
    Closed bool
    ClosedByUser bool `datastore:",noindex"`
    AutoClosed bool `datastore:",noindex"`
    Pos Position
    Events []Event
}

type Event struct{
    // Autogenerated id, not stored in the datastore.
    ID string `datastore:"-"`
    CreatedAt time.Time
    Name string `datastore:",noindex"`
}

最佳答案

Export Position 字段名称,将名称中的第一个字母大写。数据存储 stores exported fields only .

type Position struct{
  Lon float32
  Lat float32
}

关于google-app-engine - Go App Engine 嵌套对象未存储在 Cloud Datastore 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33593588/

相关文章:

python - 我需要 objectify.SubElement 的 polyfill

go - 如何获取地址以使用反射字段?

google-app-engine - 数据存储 : Multiple writes against an entity group inside a transaction exceeds write limit?

python - 在 Google App Engine 中的 for 循环中查询的有效方法?

php - 如何在 Google App Engine 上安装/使用 PhpRedis?

java - 将不同的 GWT 实现返回到 GAE 上的移动和桌面客户端

c++ - 用于 c/c++ 客户端的 Google channel API

javascript - 如何使用 Go 驱动程序或 Golang 在 Mongodb 中插入 javascritpt 函数

go - Prometheus 使用计数器对非静态数据进行计数

java - 在 App Engine 数据存储中设置文本数据类型的编码