我有一个模型:
type UserProfile struct {
UserID string `datastore:"user_id" json:"user_id,omitempty"`
Username string `datastore:"username" json:"username,omitempty"`
StripUsername string `datastore:"strip_username" json:"strip_username,omitempty"`
Email string `datastore:"email" json:"email,omitempty"`
LoginType string `datastore:"login_type" json:"login_type,omitempty"`
CurrentSession string `datastore:"current_session" json:"current_session,omitempty"`
FBAcessToken string `datastore:"fb_access_token" json:"fb_access_token,omitempty"`
Created time.Time `datastore:"created" json:"-"`
}
我执行一个 .GetAll 来填充它:
// Skip a few steps here
var userProfiles []UserProfile
q.GetAll(c, &userProfiles)
假设我想修改这些实体之一:
userProfile[0].Email = "test@example.com"
我知道我想像这样放置该实体:
k = datastore.Put(c, k, userProfile[0])
如何从 userProfile[0] 获取初始密钥以调用 Put ?
慕妹3146593
相关分类