Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Carlos
/
query-to-mongo
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
33e2dead
authored
Feb 15, 2017
by
Jose Carlos López
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix criteria when only one value is passed
parent
6be39822
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
1 deletions
index.js
test/query.js
index.js
View file @
33e2dead
...
...
@@ -116,7 +116,7 @@ function comparisonToMongo(key, value) {
array
.
push
(
typedValue
(
value
))
})
value
=
{
}
value
[
op
]
=
array
.
length
==
1
?
array
[
0
]
:
array
value
[
op
]
=
array
.
length
==
1
&&
op
!==
'$all'
?
array
[
0
]
:
array
}
else
{
value
=
typedValue
(
parts
[
3
])
if
(
op
==
'>'
)
value
=
{
'$gt'
:
value
}
...
...
test/query.js
View file @
33e2dead
...
...
@@ -152,6 +152,11 @@ describe("query-to-mongo(query) =>", function () {
assert
.
ok
(
results
)
assert
.
deepEqual
(
results
,
{
array
:
{
$all
:
[
50
,
60
]}
})
})
it
(
"should create $all criteria with one value"
,
function
()
{
var
results
=
q2m
(
"array:all=50"
)
assert
.
ok
(
results
)
assert
.
deepEqual
(
results
,
{
array
:
{
$all
:
[
50
]}
})
})
it
(
"should create forced string criteria"
,
function
()
{
var
results
=
q2m
(
"s='a,b'"
)
assert
.
ok
(
results
)
...
...
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