问题描述
在 Postgres 中,数组的 overlap ("&&") operator 用于检查两个数组是否有任何共同元素。
例如
查询 | 结果 |
---|---|
数组[1,4,3]&&数组[2,1] | 真实 |
数组[1,5] | 假 |
GraphQL 中是否有类似的东西?
另外,有什么我可以在 Hasura 中使用的吗?
- 我能想到的一个更具体的实际用例如下。 (我只是为了澄清而编写它们,并没有运行或验证语法。)
// Assume a you want to find all restaurants with any of the selected cuisines.
const restaurantA = {...,cuisineType: ['Fusion','Chinese','Japanese','Korean']}
const restaurantB = {...,cuisineType: ['vegetarian','Thai']}
const restaurantC = {...,cuisineType: ['European']}
// Assume the data above is stored in Postgres (as an array in column field,not using a bridge table.
const sql_1 = "SELECT *
FROM restaurants
WHERE cuisine_type && ['Korean','Japanese']" // Expect restaurantA and restaurantC
const sql_2 = "SELECT *
FROM restaurants
WHERE cuisine_type && ['vegetarian','European']" // Expect restaurantB and restaurantC
### GOAL: I want to use GraphQL,Apollo,Hasura to have the same effect as sql_1 and sql_2
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)