LastAccumulator.js 828 B

1234567891011121314151617181920212223242526
  1. "use strict";
  2. var LastAccumulator = module.exports = (function(){
  3. // CONSTRUCTOR
  4. /**
  5. * Constructor for LastAccumulator, wraps SingleValueAccumulator's constructor and finds the last document
  6. *
  7. * @class LastAccumulator
  8. * @namespace munge.pipeline.accumulators
  9. * @module munge
  10. * @constructor
  11. **/
  12. var klass = module.exports = function LastAccumulator(){
  13. base.call(this);
  14. }, SingleValueAccumulator = require("./SingleValueAccumulator"), base = SingleValueAccumulator, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
  15. proto.evaluate = function evaluate(doc){
  16. if(this.operands.length != 1) throw new Error("this should never happen");
  17. this.value = this.operands[0].evaluate(doc);
  18. };
  19. proto.getOpName = function getOpName(){
  20. return "$last";
  21. };
  22. return klass;
  23. })();