Hasura支持Postgres的integer[]数据类型的“contains”过滤器吗?

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

Does Hasura support "contains" filter for integer[] data types from postgres?

问题

我们正在评估从postgraphile迁移到hasura,我注意到hasura不支持integer[]类型的视图列的contains筛选选项。是否有一种方法可以启用此功能?我们有几个视图依赖contains筛选。我们使用的是postgres12和hasura 2.20.1。

英文:

We are evaluating a migration from postgraphile to hasura and what I've noticed is that hasura doesn't support a contains filter option for a view column of type integer[].

Is there a way to enable this? We have several views depending on the contains filter.

We are using postgres12 and hasura 2.20.1

Hasura支持Postgres的integer[]数据类型的“contains”过滤器吗?
Hasura支持Postgres的integer[]数据类型的“contains”过滤器吗?
Hasura支持Postgres的integer[]数据类型的“contains”过滤器吗?

答案1

得分: 0

你可以通过在Hasura中将列类型设置为JSONB来实现这一点...整数数组是有效的JSON类型,然后您可以像这样查询它:

query MyQuery {
  test_table(where: {int_json: {_contains: 2}}) {
    int_json
  }
}

然后你将会得到这样的响应:

{
  "data": {
    "test_table": [
      {
        "int_json": [
          1,
          2,
          3,
          4
        ]
      }
    ]
  }
}
英文:

You can do this by setting the column type in Hasura to JSONB... the integer array is a valid JSON type and then you can query it like this:

query MyQuery {
  test_table(where: {int_json: {_contains: 2}}) {
    int_json
  }
}

and you will get a response like this:

{
  "data": {
    "test_table": [
      {
        "int_json": [
          1,
          2,
          3,
          4
        ]
      }
    ]
  }
}

huangapple
  • 本文由 发表于 2023年4月11日 03:30:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/75980105.html
匿名

发表评论

匿名网友

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

确定