FalseMatchExpression.js 1.6 KB

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