自动在Go中从数据存储中包含ID

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

Automatically include ID from datastore in Go

问题

我正在使用App Engine上的Go语言。我正在从App Engine数据存储加载结构化数据。目前,我必须在从数据存储加载对象后从键中获取对象ID,然后将其分配给对象。在App Engine管理面板中,当我使用数据存储查看器时,我可以看到键和ID值。

我能否自动将键或数字ID作为属性从数据存储加载到加载的对象中?(使用或不使用PropertyLoader接口)。

这样,我就不必在查询后始终通过解析给定的键来包含它。

英文:

I'm using Go on App Engine. I'm loading struct data from App Engine datastore. Currently I have to get the object ID from the key after the object is loaded from the datastore and then assign it to the object. In App Engine admin panel I can see the key and ID value when I'm using the datastore viewer.

Can I automatically include the key OR the numerical ID as a property from the datastore to the loaded object? (with or without using PropertyLoader interface).

That way I wouldn't have to include it always after the query by parsing it from the given key.

答案1

得分: 1

我相信简短的答案是“不”,在appengine/datastore中没有提供自动发生这种情况的功能。请参阅此讨论主题

英文:

I believe the short answer is "no", there's nothing provided in appengine/datastore to have that happen automatically. See this groups topic.

huangapple
  • 本文由 发表于 2013年2月18日 02:53:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/14924765.html
匿名

发表评论

匿名网友

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

确定