|
|
@@ -19,12 +19,6 @@ var Value = require("../Value"),
|
|
|
OrExpression = require("./OrExpression"),
|
|
|
NotExpression = require("./NotExpression");
|
|
|
|
|
|
-// PROTOTYPE MEMBERS
|
|
|
-proto.evaluate = function evaluate(doc){
|
|
|
- var result = this.expression.evaluate(doc);
|
|
|
- return Value.coerceToBool(result);
|
|
|
-};
|
|
|
-
|
|
|
proto.optimize = function optimize() {
|
|
|
this.expression = this.expression.optimize(); // optimize the operand
|
|
|
|
|
|
@@ -43,6 +37,21 @@ proto.addDependencies = function addDependencies(deps, path) {
|
|
|
return this.expression.addDependencies(deps);
|
|
|
};
|
|
|
|
|
|
+// PROTOTYPE MEMBERS
|
|
|
+proto.evaluateInternal = function evaluateInternal(doc){
|
|
|
+ var result = this.expression.evaluateInternal(doc);
|
|
|
+ return Value.coerceToBool(result);
|
|
|
+};
|
|
|
+
|
|
|
+proto.serialize = function serialize(explain) {
|
|
|
+ if ( explain ) {
|
|
|
+ return {$coerceToBool:[this.expression.toJSON()]};
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return {$and:[this.expression.toJSON()]};
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
proto.toJSON = function toJSON() {
|
|
|
// Serializing as an $and expression which will become a CoerceToBool
|
|
|
return {$and:[this.expression.toJSON()]};
|