|
@@ -2,36 +2,42 @@
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* A $toUpper pipeline expression.
|
|
* A $toUpper pipeline expression.
|
|
|
- * @see evaluate
|
|
|
|
|
|
|
+ * @see evaluateInternal
|
|
|
* @class ToUpperExpression
|
|
* @class ToUpperExpression
|
|
|
* @namespace mungedb-aggregate.pipeline.expressions
|
|
* @namespace mungedb-aggregate.pipeline.expressions
|
|
|
* @module mungedb-aggregate
|
|
* @module mungedb-aggregate
|
|
|
* @constructor
|
|
* @constructor
|
|
|
**/
|
|
**/
|
|
|
-var ToUpperExpression = module.exports = function ToUpperExpression(){
|
|
|
|
|
- if (arguments.length !== 0) throw new Error("zero args expected");
|
|
|
|
|
- base.call(this);
|
|
|
|
|
-}, klass = ToUpperExpression, base = require("./NaryExpression"), proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
|
|
|
|
|
|
|
+var ToUpperExpression = module.exports = function ToUpperExpression() {
|
|
|
|
|
+ this.fixedAirty(1);
|
|
|
|
|
+ if (arguments.length !== 0) throw new Error("zero args expected");
|
|
|
|
|
+ base.call(this);
|
|
|
|
|
+}, klass = ToUpperExpression,
|
|
|
|
|
+ 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(){
|
|
|
|
|
- return "$toUpper";
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
-proto.addOperand = function addOperand(expr) {
|
|
|
|
|
- this.checkArgLimit(1);
|
|
|
|
|
- base.prototype.addOperand.call(this, expr);
|
|
|
|
|
|
|
+proto.getOpName = function getOpName() {
|
|
|
|
|
+ return "$toUpper";
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
-* Takes a single string and converts that string to lowercase, returning the result. All uppercase letters become lowercase.
|
|
|
|
|
-**/
|
|
|
|
|
-proto.evaluate = function evaluate(doc) {
|
|
|
|
|
- this.checkArgCount(1);
|
|
|
|
|
- var val = this.operands[0].evaluate(doc),
|
|
|
|
|
- str = Value.coerceToString(val);
|
|
|
|
|
- return str.toUpperCase();
|
|
|
|
|
|
|
+ * Takes a single string and converts that string to lowercase, returning the result. All uppercase letters become lowercase.
|
|
|
|
|
+ **/
|
|
|
|
|
+proto.evaluateInternal = function evaluateInternal(doc) {
|
|
|
|
|
+ this.checkArgCount(1);
|
|
|
|
|
+ var val = this.operands[0].evaluateInternal(doc),
|
|
|
|
|
+ str = Value.coerceToString(val);
|
|
|
|
|
+ return str.toUpperCase();
|
|
|
};
|
|
};
|
|
|
|
|
+
|
|
|
|
|
+/** Register Expression */
|
|
|
|
|
+Expression.registerExpression("$toUpper", ToUpperExpression.parse);
|