Commit 3bb0f7b31f60398123a79da40285b3668af651ee
1 parent
33bc3ee6
Exists in
master
and in
17 other branches
Added docs for prefix and remove _ with exists
Showing
3 changed files
with
13 additions
and
12 deletions
Show diff stats
README.md
... | ... | @@ -99,17 +99,18 @@ Where |
99 | 99 | |
100 | 100 | ```ruby |
101 | 101 | where: { |
102 | - expires_at: {gt: Time.now}, # lt, gte, lte also available | |
103 | - orders_count: 1..10, # equivalent to {gte: 1, lte: 10} | |
104 | - aisle_id: [25, 30], # in | |
105 | - store_id: {not: 2}, # not | |
106 | - aisle_id: {not: [25, 30]}, # not in | |
107 | - user_ids: {all: [1, 3]}, # all elements in array | |
108 | - category: /frozen .+/, # regexp | |
109 | - store_id: {_exists: true}, # exists [master] | |
102 | + expires_at: {gt: Time.now}, # lt, gte, lte also available | |
103 | + orders_count: 1..10, # equivalent to {gte: 1, lte: 10} | |
104 | + aisle_id: [25, 30], # in | |
105 | + store_id: {not: 2}, # not | |
106 | + aisle_id: {not: [25, 30]}, # not in | |
107 | + user_ids: {all: [1, 3]}, # all elements in array | |
108 | + category: /frozen .+/, # regexp | |
109 | + store_id: {exists: true}, # exists [master] | |
110 | + category: {prefix: "Frozen"}, # prefix | |
110 | 111 | _or: [{in_stock: true}, {backordered: true}], |
111 | 112 | _and: [{in_stock: true}, {backordered: true}], |
112 | - _not: {store_id: 1} # negate a condition | |
113 | + _not: {store_id: 1} # negate a condition | |
113 | 114 | } |
114 | 115 | ``` |
115 | 116 | ... | ... |
lib/searchkick/query.rb
test/where_test.rb
... | ... | @@ -68,8 +68,8 @@ class WhereTest < Minitest::Test |
68 | 68 | assert_search "product", ["Product B", "Product C"], where: {user_ids: {_not: [2], in: [1, 3]}} |
69 | 69 | |
70 | 70 | # exists |
71 | - assert_search "product", ["Product A", "Product B", "Product C"], where: {user_ids: {_exists: true}} | |
72 | - assert_search "product", ["Product A", "Product B", "Product C", "Product D"], where: {store_id: {_exists: true}} | |
71 | + assert_search "product", ["Product A", "Product B", "Product C"], where: {user_ids: {exists: true}} | |
72 | + assert_search "product", ["Product A", "Product B", "Product C", "Product D"], where: {store_id: {exists: true}} | |
73 | 73 | |
74 | 74 | # not |
75 | 75 | assert_search "product", ["Product D"], where: {user_ids: nil} | ... | ... |