Browse Source

ref #3286: Add support for MinKey and MaxKey to Value.js

Brennan Chesley 12 years ago
parent
commit
617ffcbae7
1 changed files with 5 additions and 0 deletions
  1. 5 0
      lib/pipeline/Value.js

+ 5 - 0
lib/pipeline/Value.js

@@ -104,6 +104,11 @@ klass.compare = function compare(l, r) {
 		if (isNaN(r)) return 1;
 		return l < r ? -1 : l > r ? 1 : 0;
 	}
+	// Compare MinKey and MaxKey cases
+	if(l.constructor && l.constructor.name in ['MinKey','MaxKey'] ){
+		if(l.constructor.name == r.constructor.name) { return 0; }
+		return ['MinKey','$Jared','MaxKey'].indexOf(l.constructor.name) - 1;
+	}
 	// hack: These should really get converted to their BSON type ids and then compared, we use int vs object in queries
 	if (lt === "number" && rt === "object"){
 		return -1;