PushAccumulator.js 686 B

123456789101112131415161718192021222324252627282930
  1. var PushAccumulator = module.exports = (function(){
  2. // Constructor
  3. var klass = module.exports = function PushAccumulator(){
  4. this.values = [];
  5. base.call(this);
  6. }, Accumulator = require("./Accumulator"), base = Accumulator, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
  7. proto.evaluate = function evaluate(doc){
  8. if(this.operands.length != 1) throw new Error("this should never happen");
  9. var v = this.operands[0].evaluate(doc);
  10. if(v)
  11. this.values.push(v);
  12. return null;
  13. };
  14. proto.getValue = function getValue(){
  15. return this.values;
  16. };
  17. proto.getOpName = function getOpName(){
  18. return "$push";
  19. };
  20. return klass;
  21. })();