Commit 33bc3ee662be14d4cc04278613fe4d1d011dcad7
1 parent
bbc2217f
Exists in
master
and in
17 other branches
Added exists
Showing
3 changed files
with
8 additions
and
1 deletions
Show diff stats
README.md
... | ... | @@ -106,6 +106,7 @@ where: { |
106 | 106 | aisle_id: {not: [25, 30]}, # not in |
107 | 107 | user_ids: {all: [1, 3]}, # all elements in array |
108 | 108 | category: /frozen .+/, # regexp |
109 | + store_id: {_exists: true}, # exists [master] | |
109 | 110 | _or: [{in_stock: true}, {backordered: true}], |
110 | 111 | _and: [{in_stock: true}, {backordered: true}], |
111 | 112 | _not: {store_id: 1} # negate a condition | ... | ... |
lib/searchkick/query.rb
test/where_test.rb
... | ... | @@ -67,7 +67,11 @@ class WhereTest < Minitest::Test |
67 | 67 | assert_search "product", ["Product B", "Product C"], where: {user_ids: {not: [2], in: [1, 3]}} |
68 | 68 | assert_search "product", ["Product B", "Product C"], where: {user_ids: {_not: [2], in: [1, 3]}} |
69 | 69 | |
70 | - # not / exists | |
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}} | |
73 | + | |
74 | + # not | |
71 | 75 | assert_search "product", ["Product D"], where: {user_ids: nil} |
72 | 76 | assert_search "product", ["Product A", "Product B", "Product C"], where: {user_ids: {not: nil}} |
73 | 77 | assert_search "product", ["Product A", "Product B", "Product C"], where: {user_ids: {_not: nil}} | ... | ... |