尝试允许通用数组或值查询,如 rails 用于允许 where(a: [1]) 或 where(a: 1) 工作等等
Trying to allow for generalized array or value queries like rails uses to allow for where(a: [1]) or where(a: 1) to work and more
所以我正在搜索的数据类似于(其中数百个具有各种值组合):
attributes1:
attr1: "1",
attr2: "3",
attr3: ["A,"B"],
attributes2:
attr1: "2",
attr2: "5",
attr3: ["B,"D"],
attributes3:
attr1: "2",
attr2: "4",
attr3: ["B,"D"],
我遇到了这个:
哪个很接近但不完全存在(不工作,不清楚原因)。
虽然复杂,但查询是预定义的并用于填充下拉菜单,所以像 { attr3: "A", attr2: "4" }
和 { attr1: ["1", "2"]} }
这样的东西。基本上很笼统。
我让它为更简单的情况工作 { attr1: "2" }
产生 attributes2
和 attributes3
(或 attr1: '2", attr2: "4"
只给出 attributes3
,但也尝试现在将数组作为属性值和查询值处理。
在使用 attrX:
中的每个值之前,您可以使用 Array()
.
对其进行转换
# Will wrap in an Array
Array("1") => ["1"]
# Will return the original Array
Array(["1"]) => ["1"]
任何使用那天的方法都可以写成总是期望一个数组。
所以我正在搜索的数据类似于(其中数百个具有各种值组合):
attributes1:
attr1: "1",
attr2: "3",
attr3: ["A,"B"],
attributes2:
attr1: "2",
attr2: "5",
attr3: ["B,"D"],
attributes3:
attr1: "2",
attr2: "4",
attr3: ["B,"D"],
我遇到了这个:
哪个很接近但不完全存在(不工作,不清楚原因)。
虽然复杂,但查询是预定义的并用于填充下拉菜单,所以像 { attr3: "A", attr2: "4" }
和 { attr1: ["1", "2"]} }
这样的东西。基本上很笼统。
我让它为更简单的情况工作 { attr1: "2" }
产生 attributes2
和 attributes3
(或 attr1: '2", attr2: "4"
只给出 attributes3
,但也尝试现在将数组作为属性值和查询值处理。
在使用 attrX:
中的每个值之前,您可以使用 Array()
.
# Will wrap in an Array
Array("1") => ["1"]
# Will return the original Array
Array(["1"]) => ["1"]
任何使用那天的方法都可以写成总是期望一个数组。