Skip to content

Commit

Permalink
Fix date problem
Browse files Browse the repository at this point in the history
  • Loading branch information
Fizcko committed May 29, 2019
1 parent c58e4ae commit cd4b7d0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const rsqlMongoDB = require('rsql-mongodb');

try{

// String comparison : you have to add quotes for string values
// String comparison : you can add quotes for string values
rsqlMongoDB('lastName=="doe"');
//=> { "lastName" : "doe" }

Expand All @@ -50,7 +50,7 @@ try{

// Date comparison
rsqlMongoDB('birthday=ge=1959-10-21');
//=> { "birthday": { $gte: new Date("1959-10-21") } }
//=> { "birthday": { $gte: new Date("1959-10-21T00:00:00.000Z") } }

// In comparison
rsqlMongoDB('childs=in=(1,2,3)');
Expand All @@ -61,7 +61,7 @@ try{
//=> { "childs": { $nin: [1,2,3] } }

// Groups
rsqlMongoDB('(firstName=="john";lastName=="doe"),(firstName=="janne";lastName=="doe")');
rsqlMongoDB('(firstName=="john";lastName=="doe"),(firstName==janne;lastName==doe)');
//=> { $or: [ { $and: [ { "firstName" : "john" } , { "lastName" : "doe" } ] } , { $and: [ { "firstName" : "janne" } , { "lastName" : "doe" } ] } ] }

}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rsql-mongodb",
"version": "1.1.0",
"version": "1.1.1",
"description": "Converting RSQL queries to MongoDB queries",
"main": "rsql-mongodb.js",
"typings": "rsql-mongodb.ts",
Expand Down
3 changes: 2 additions & 1 deletion rsql-mongodb.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ function setType(input) {
}
else if(matchDate.exec(input)){
if(Date.parse(input)){
typedInput = new Date('"' + input + '"');
var isoUTCDate = new Date(input).toISOString();
typedInput = new Date('"' + isoUTCDate + '"');
}
}

Expand Down

0 comments on commit cd4b7d0

Please sign in to comment.