【发布时间】:2019-08-29 00:19:12
【问题描述】:
我总是遇到问题,调用时:GoogleApi.Firestore.V1beta1.Api.Projects.firestore_projects_databases_documents_run_query(),如下图。
我已经尝试过不同的输入和格式化方式,以及不同的 Firestore 集合。
{:ok, token} = Goth.Token.for_scope("https://www.googleapis.com/auth/cloud-platform")
conn = GoogleApi.Firestore.V1beta1.Connection.new(token.token)
query = %GoogleApi.Firestore.V1beta1.Model.RunQueryRequest{
structuredQuery: %{
:from => %{:collectionId => "demo"},
:limit => 1
}
}
GoogleApi.Firestore.V1beta1.Api.Projects.firestore_projects_databases_documents_run_query(
conn,
"projects/demo/databases/(default)/documents",
body: query
)
结果:
** (BadMapError) expected a map, got: [%{"readTime" => "2019-04-07T20:23:48.219664Z"}]
(elixir) lib/map.ex:437: Map.get([%{"readTime" => "2019-04-07T20:23:48.219664Z"}], "document", nil)
lib/poison/decoder.ex:53: anonymous fn/3 in Poison.Decode.transform_struct/4
(stdlib) maps.erl:257: :maps.fold_1/3
lib/poison/decoder.ex:52: Poison.Decode.transform_struct/4
lib/poison.ex:70: Poison.decode/2
【问题讨论】:
-
嗨@dominik,有趣的是我有同样的错误;无论如何,我开始使用您的示例来了解库是如何工作的,因为完全没有示例(即使在测试文件夹中:/)。
标签: google-cloud-platform google-cloud-firestore elixir