Skip to content

Commit

Permalink
Merge pull request #586 from kapouer/patch-1
Browse files Browse the repository at this point in the history
[mongodb] fix ne, eq comparators for _id key
  • Loading branch information
dresende committed Dec 22, 2014
2 parents 4440c22 + 51c9377 commit 3cb0559
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/Drivers/DML/mongodb.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ function convertFromDB(obj, timezone) {

function convertToDBVal(key, value, timezone) {
if (value && typeof value.sql_comparator == "function") {
var val = (key != "_id" ? value : new mongodb.ObjectID(value));
var val = (key != "_id" ? value.val : new mongodb.ObjectID(value.val));
var comp = value.sql_comparator();
var condition = {};

Expand All @@ -406,17 +406,17 @@ function convertToDBVal(key, value, timezone) {
case "lt":
case "lte":
case "ne":
condition["$" + comp] = val.val;
condition["$" + comp] = val;
break;
case "eq":
condition = val.val;
condition = val;
break;
case "between":
condition["$min"] = val.from;
condition["$max"] = val.to;
condition["$min"] = value.from;
condition["$max"] = value.to;
break;
case "like":
condition["$regex"] = val.expr.replace("%", ".*");
condition["$regex"] = value.expr.replace("%", ".*");
break;
}

Expand Down

0 comments on commit 3cb0559

Please sign in to comment.