英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论