FalseMatchExpression.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. "use strict";
  2. var MatchExpression = require('./MatchExpression');
  3. /**
  4. * A match expression that always returns false
  5. * @class FalseMatchExpression
  6. * @namespace mungedb-aggregate.pipeline.matcher
  7. * @module mungedb-aggregate
  8. * @constructor
  9. **/
  10. var FalseMatchExpression = module.exports = function FalseMatchExpression(){
  11. base.call(this);
  12. this._matchType = 'ALWAYS_FALSE';
  13. }, klass = FalseMatchExpression, base = MatchExpression, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
  14. /**
  15. *
  16. * Writes a debug string for this object
  17. * @method debugString
  18. * @param level
  19. *
  20. */
  21. proto.debugString = function debugString(level) {
  22. return this._debugAddSpace( level ) + "$false\n";
  23. };
  24. /**
  25. *
  26. * checks if this expression is == to the other
  27. * @method equivalent
  28. * @param other
  29. *
  30. */
  31. proto.equivalent = function equivalent(other) {
  32. return other._matchType === this._matchType;
  33. };
  34. /**
  35. *
  36. * matches checks the input doc against the internal element path to see if it is a match
  37. * @method matches
  38. * @param doc
  39. * @param details
  40. *
  41. */
  42. proto.matches = function matches(doc,details) {
  43. return false;
  44. };
  45. /**
  46. *
  47. * Check if the input element matches
  48. * @method matchesSingleElement
  49. * @param e
  50. *
  51. */
  52. proto.matchesSingleElement = function matchesSingleElement(e) {
  53. return false;
  54. };
  55. /**
  56. *
  57. * clone this instance to a new one
  58. * @method shallowClone
  59. *
  60. */
  61. proto.shallowClone = function shallowClone(){
  62. return new FalseMatchExpression();
  63. };
  64. /**
  65. *
  66. * append to JSON object
  67. * @method shallowClone
  68. *
  69. */
  70. proto.toJson = function toJson(out){
  71. out.$false = 1;
  72. return out;
  73. };