我有一个 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/