[英]How to define a Key type in datastore?
我有一个用户类型:
type User struct {
Username string
Email string
Password string
}
还有一个帖子种类:
type Post struct {
User // how to define here?
Title string
Content string
}
帖子实体看起来像:
用户:密钥(用户,“ 10000”)
标题:“一些倾斜”
内容:“一些内容”
如何定义Post.User
?
由于您的Post
实体包含完整的Key
,因此请使用datastore.Key
作为字段类型:
type Post struct {
User *datastore.Key
Title string
Content string
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.