【发布时间】:2021-02-23 19:06:08
【问题描述】:
我想从一种数据存储类型中读取所有实体(大约 6 个实体/记录)。
我有一个数据存储区,该数据存储区键入了我想要理解的奇怪类型。我在执行查询的键上找不到任何唯一性。
The table looks like this:
GCP Datastore representing data I want to read into my Go app
When I click on a record, it looks like this:
Key literal exposed and used from here on out to try and get the records in the Go app
``我可以像这样在控制台中执行祖先查询:``` GCP Datastore queried using Ancestor query
太棒了!所以现在我想从我的 Golang 应用程序中检索这些数据?但是怎么做?
我在网上看到很多关于使用q.Get(...) // where q is a *Query struct 的解决方案
这些解决方案中的任何一个都不起作用,因为它们导入了google.golang.org/appengine/datastore。我知道这是遗留问题并且已被弃用。所以我想要一个导入cloud.google.com/go/datastore的解决方案。
我尝试了一些类似的方法,但运气不佳: First try using GetAll and query
接下来我尝试了这个: Second try attempting to use ancestor query... not ready yet
最后我尝试直接获取一条记录: Lastly I tried to get the record directly
在所有情况下,我的err 不为零,应该从数据存储查询填充的dts 也为零。
有任何指导可以帮助我了解如何查询此键类型吗?我是否错过了该表的键控和查询方式的一些基本内容?
谢谢
然后我尝试了这个:
【问题讨论】:
-
请编辑您的帖子,包括代码而不是图片。
标签: go google-cloud-platform google-cloud-datastore deprecated ancestor