Ron*_*ell 1 google-app-engine go
我正在尝试使用Google App Engine在Go中编写一个webapp,我有一个关于使用数据存储建模关系的问题.
我知道在Python中我可以使用db.referenceProperty()建模关系.我似乎无法弄清楚如何使用Go API建立类似的关联.
有人有运气吗?
您可以将Key用作实体中的属性:http://code.google.com/appengine/docs/go/datastore/reference.html
像这样的东西(我不知道去跟我一起吃):
type Employee struct {
Name string
Boss *Key
}
employee := Employee{
Name: "John Doe",
Boss: key // a key to some other entity
}
Run Code Online (Sandbox Code Playgroud)