Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
ta_ransack_mongo
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
ta_ransack_mongo
Commits
1700a25f
Commit
1700a25f
authored
Feb 13, 2022
by
liyijie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 增加null和not_null支持
parent
f27138cc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
1 deletion
+10
-1
mongo_adapter.rb
lib/ransack_mongo/mongo_adapter.rb
+9
-1
predicate.rb
lib/ransack_mongo/predicate.rb
+1
-0
No files found.
lib/ransack_mongo/mongo_adapter.rb
View file @
1700a25f
module
RansackMongo
module
RansackMongo
class
MongoAdapter
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
def
initialize
@query
=
{}
@query
=
{}
...
@@ -10,6 +10,14 @@ module RansackMongo
...
@@ -10,6 +10,14 @@ module RansackMongo
@query
@query
end
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
)
def
eq_matcher
(
attr
,
value
)
@query
[
attr
]
=
value
@query
[
attr
]
=
value
end
end
...
...
lib/ransack_mongo/predicate.rb
View file @
1700a25f
...
@@ -5,6 +5,7 @@ module RansackMongo
...
@@ -5,6 +5,7 @@ module RansackMongo
end
end
def
parse
(
params
)
def
parse
(
params
)
binding
.
pry
(
params
||
{}).
keys
.
inject
({})
do
|
query
,
query_param
|
(
params
||
{}).
keys
.
inject
({})
do
|
query
,
query_param
|
attr
=
query_param
.
to_s
attr
=
query_param
.
to_s
p
,
attr
=
detect_and_strip_from_string
(
attr
)
p
,
attr
=
detect_and_strip_from_string
(
attr
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment