【问题标题】:Query on Array of strings to get matched values from Datastore查询字符串数组以从数据存储区获取匹配值
【发布时间】:2020-04-29 17:40:39
【问题描述】:

我有以下结构是的场景

type Band struct {
Name       string  `json:"name"`
Albums     []String `json:"album"`
GradeLevel []string   `json:"gradeLevel,omitempty"`
Topics     []string   `json:"topics,omitempty"`

}

数据存储方式类似于 (示例)

**Name          Albums           GradeLevel               Topics**
Sample   ["sample","Test"]      ["grade1"]         ["Children","Poems"]
test        ["Test"]        ["grade2","grade1"]      ["therapy","slow"]

这里如何使用给定的输入查询以从 Band 类型中获取适当的值,例如 查询请求是{"album" : ["sample","Test"] , "gradeLevel" : ["grade1"] , "topic" : ["poem"]}

可以从前端组合输入,因此如何查询基于输入以显示上述场景的值列表。

【问题讨论】:

    标签: go google-cloud-datastore google-app-engine-golang


    【解决方案1】:

    您可以在此处找到有关在 Go 中编写查询以在 Datastore 模式下从 Firestore 检索数据的信息 [1]。要查询数组是否包含值,您需要使用相等过滤器 [2]。

    [1]https://cloud.google.com/datastore/docs/concepts/queries

    [2]https://cloud.google.com/datastore/docs/concepts/queries#array_values

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-04-08
      • 1970-01-01
      • 2017-08-22
      • 2013-05-16
      • 2012-05-03
      • 1970-01-01
      • 2014-02-06
      • 2021-01-28
      相关资源
      最近更新 更多