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