MatchOp.js 540 B

1234567891011121314151617181920
  1. var Op = require("../Op"),
  2. sift = require("sift");
  3. /** The $match operator; opts is the expression to be used when matching Objects. **/
  4. var MatchOp = module.exports = (function(){
  5. // CONSTRUCTOR
  6. var base = Op, proto, klass = function MatchOp(opts){
  7. this.sifter = sift(opts);
  8. base.call(this, opts);
  9. };
  10. proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
  11. // PROTOTYPE MEMBERS
  12. proto.write = function writeIfMatches(obj){
  13. if(this.sifter.test(obj))
  14. this.queue(obj);
  15. };
  16. return klass;
  17. })();