LastAccumulator.js 881 B

1234567891011121314151617181920212223242526272829303132
  1. "use strict";
  2. /**
  3. * Constructor for LastAccumulator, wraps SingleValueAccumulator's constructor and finds the last document
  4. * @class LastAccumulator
  5. * @namespace mungedb-aggregate.pipeline.accumulators
  6. * @module mungedb-aggregate
  7. * @constructor
  8. **/
  9. var LastAccumulator = module.exports = function LastAccumulator(){
  10. base.call(this);
  11. this.value = undefined;
  12. }, klass = LastAccumulator, base = require("./Accumulator"), proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
  13. // NOTE: Skipping the create function, using the constructor instead
  14. // MEMBER FUNCTIONS
  15. proto.processInternal = function processInternal(input, merging){
  16. this.value = input;
  17. };
  18. proto.getValue = function getValue() {
  19. return this.value;
  20. };
  21. proto.getOpName = function getOpName(){
  22. return "$last";
  23. };
  24. proto.reset = function reset() {
  25. this.value = undefined;
  26. };