SingleValueAccumulator.js 896 B

123456789101112131415161718192021222324
  1. "use strict";
  2. /**
  3. * This isn't a finished accumulator, but rather a convenient base class
  4. * for others such as $first, $last, $max, $min, and similar. It just
  5. * provides a holder for a single Value, and the getter for that. The
  6. * holder is protected so derived classes can manipulate it.
  7. *
  8. * @class SingleValueAccumulator
  9. * @namespace mungedb-aggregate.pipeline.accumulators
  10. * @module mungedb-aggregate
  11. * @constructor
  12. **/
  13. var SingleValueAccumulator = module.exports = function SingleValueAccumulator(){
  14. if (arguments.length > 1) throw new Error("expects a single value");
  15. base.call(this);
  16. }, klass = SingleValueAccumulator, Accumulator = require("./Accumulator"), base = Accumulator, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
  17. // DEPENDENCIES
  18. var Value = require("../Value");
  19. proto.getValue = function getValue(){
  20. return this.value;
  21. };