Просмотр исходного кода

REFS DEVOPS-246 Added v2.5 compatibility

David Aebersold 12 лет назад
Родитель
Сommit
f4535223ce
1 измененных файлов с 10 добавлено и 11 удалено
  1. 10 11
      lib/pipeline/expressions/DivideExpression.js

+ 10 - 11
lib/pipeline/expressions/DivideExpression.js

@@ -2,7 +2,7 @@
 
 
 /** 
 /** 
  * A $divide pipeline expression. 
  * A $divide pipeline expression. 
- * @see evaluate 
+ * @see evaluateInternal 
  * @class DivideExpression
  * @class DivideExpression
  * @namespace mungedb-aggregate.pipeline.expressions
  * @namespace mungedb-aggregate.pipeline.expressions
  * @module mungedb-aggregate
  * @module mungedb-aggregate
@@ -14,29 +14,28 @@ var DivideExpression = module.exports = function DivideExpression(){
 }, klass = DivideExpression, base = require("./NaryExpression"), proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
 }, klass = DivideExpression, base = require("./NaryExpression"), proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
 
 
 // DEPENDENCIES
 // DEPENDENCIES
-var Value = require("../Value");
+var Value = require("../Value"),
+		Expression = require("./Expression");
 
 
 // PROTOTYPE MEMBERS
 // PROTOTYPE MEMBERS
 proto.getOpName = function getOpName(){	//TODO: try to move this to a static and/or instance field instead of a getter function
 proto.getOpName = function getOpName(){	//TODO: try to move this to a static and/or instance field instead of a getter function
 	return "$divide";
 	return "$divide";
 };
 };
 
 
-proto.addOperand = function addOperand(expr){
-	this.checkArgLimit(2);
-	base.prototype.addOperand.call(this, expr);
-};
-
 /**
 /**
  * Takes an array that contains a pair of numbers and returns the value of the first number divided by the second number.
  * Takes an array that contains a pair of numbers and returns the value of the first number divided by the second number.
- * @method evaluate
+ * @method evaluateInternal
  **/
  **/
-proto.evaluate = function evaluate(doc) {
+proto.evaluateInternal = function evaluateInternal(doc) {
 	this.checkArgCount(2);
 	this.checkArgCount(2);
-	var left = this.operands[0].evaluate(doc),
-		right = this.operands[1].evaluate(doc);
+	var left = this.operands[0].evaluateInternal(doc),
+		right = this.operands[1].evaluateInternal(doc);
 	if (!(left instanceof Date) && (!right instanceof Date)) throw new Error("$divide does not support dates; code 16373");
 	if (!(left instanceof Date) && (!right instanceof Date)) throw new Error("$divide does not support dates; code 16373");
 	right = Value.coerceToDouble(right);
 	right = Value.coerceToDouble(right);
 	if (right === 0) return undefined;
 	if (right === 0) return undefined;
 	left = Value.coerceToDouble(left);
 	left = Value.coerceToDouble(left);
 	return left / right;
 	return left / right;
 };
 };
+
+/** Register Expression */
+Expression.registerExpression("$divide",DivideExpression.parse);