Commit 1700a25f by liyijie

feat: 增加null和not_null支持

parent f27138cc
module RansackMongo
class MongoAdapter
PREDICATES = %w[eq not_eq cont in start mstart gt lt gteq lteq]
PREDICATES = %w[null not_null eq not_eq cont in start mstart gt lt gteq lteq]
def initialize
@query = {}
......@@ -10,6 +10,14 @@ module RansackMongo
@query
end
def null_matcher(attr, value)
@query[attr] = nil
end
def not_null_matcher(attr, value)
@query[attr] = { '$ne' => nil }
end
def eq_matcher(attr, value)
@query[attr] = value
end
......
......@@ -5,6 +5,7 @@ module RansackMongo
end
def parse(params)
binding.pry
(params || {}).keys.inject({}) do |query, query_param|
attr = query_param.to_s
p, attr = detect_and_strip_from_string(attr)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment