Google Datastore中的嵌套实体在Golang中的处理方式

huangapple go评论87阅读模式
英文:

Google Datastore nested entity's in Golang

问题

我在设计我的模型时遇到了一些问题,因为我的模型包含了一个切片的切片,我得到了一个错误信息:

将嵌套结构展平会导致切片的切片

在设计这样的模型时,最好的方法是什么?

我更倾向于改变我的设计,而不是像这篇帖子中建议的那样创建自己的序列化方法:

https://stackoverflow.com/questions/20710802/loading-datastore-entities-from-python-project-in-go-leads-to-nested-structs-sli

type Inner2 struct {
	Y      float64
	inner3 []Inner3
}

type Inner3 struct {
	Z bool
}

type Outer struct {
	A int16
	I []Inner2
}
英文:

I having some problems with design my model ,
Because my model contains slice of a slice and im getting an error

flattening nested structs leads to a slice of slices

What will be the best approach to design something like that

I prefer to change my design instead of create my own serialize method like suggested in this post:

https://stackoverflow.com/questions/20710802/loading-datastore-entities-from-python-project-in-go-leads-to-nested-structs-sli

type Inner2 struct {
	Y      float64
	inner3 []Inner3
}

type Inner3 struct {
	Z bool
}

type Outer struct {
	A int16
	I []Inner2
}

答案1

得分: 2

这个问题将在几天内修复,修复的地方是 cloud.google.com/go/datastore,将支持嵌套实体值!

详细信息请参阅此帖子:
https://groups.google.com/forum/#!topic/google-api-go-announce/79jtrdeuJAg

英文:

Fix for this is coming in a few days to cloud.google.com/go/datastore -- support for nested entity values!

See post here for details:
https://groups.google.com/forum/#!topic/google-api-go-announce/79jtrdeuJAg

huangapple
  • 本文由 发表于 2015年3月26日 17:50:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/29275359.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定