ElemMatchValueMatchExpression.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. "use strict";
  2. var ArrayMatchingMatchExpression = require('./ArrayMatchingMatchExpression.js');
  3. // Autogenerated by cport.py on 2013-09-17 14:37
  4. var ElemMatchValueMatchExpression = module.exports = function ElemMatchValueMatchExpression(){
  5. this._matchType = 'ELEM_MATCH_VALUE';
  6. }, klass = ElemMatchValueMatchExpression, base = ArrayMatchingMatchExpression, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
  7. // DEPENDENCIES
  8. var errors = require("../../Errors.js"),
  9. ErrorCodes = errors.ErrorCodes;
  10. // File: expression_array.h lines: 108-108
  11. proto._subs = undefined;
  12. /**
  13. *
  14. * This documentation was automatically generated. Please update when you touch this function.
  15. * @method _arrayElementMatchesAll
  16. * @param
  17. *
  18. */
  19. proto._arrayElementMatchesAll = function _arrayElementMatchesAll(element){
  20. // File: expression_array.cpp lines: 152-157
  21. for (var i = 0; i < this._subs.length; i++ ) {
  22. if (!this._subs[i].matchesSingleElement(element))
  23. return false;
  24. }
  25. return true;
  26. };
  27. /**
  28. *
  29. * This documentation was automatically generated. Please update when you touch this function.
  30. * @method add
  31. * @param
  32. *
  33. */
  34. proto.add = function add(sub){
  35. // File: expression_array.cpp lines: 132-134
  36. if (!sub) throw new Error(sub + " ElemMatchValueMatchExpression:36");
  37. this._subs.push(sub);
  38. };
  39. /**
  40. *
  41. * This documentation was automatically generated. Please update when you touch this function.
  42. * @method debugString
  43. * @param
  44. *
  45. */
  46. proto.debugString = function debugString(level){
  47. // File: expression_array.cpp lines: 160-165
  48. var debug = this._debugAddSpace(level);
  49. debug = debug + this.path() + " $elemMatch\n";
  50. for (var i = 0; i < this._subs.length; i++) {
  51. debug = debug + this._subs[i].debugString(level + 1);
  52. }
  53. return debug;
  54. };
  55. /**
  56. *
  57. * This documentation was automatically generated. Please update when you touch this function.
  58. * @method getChild
  59. * @param
  60. *
  61. */
  62. proto.getChild = function getChild(i){
  63. // File: expression_array.h lines: 103-102
  64. return this._subs[i];
  65. };
  66. /**
  67. *
  68. * This documentation was automatically generated. Please update when you touch this function.
  69. * @method init
  70. * @param
  71. *
  72. */
  73. proto.init = function init(path, sub){
  74. // File: expression_array.cpp lines: 121-124
  75. this.init(path);
  76. this.add(sub);
  77. return {code:ErrorCodes.OK};
  78. };
  79. /**
  80. *
  81. * This documentation was automatically generated. Please update when you touch this function.
  82. * @method matchesArray
  83. * @param
  84. *
  85. */
  86. proto.matchesArray = function matchesArray(anArray, details){
  87. // File: expression_array.cpp lines: 137-149
  88. for (var i in anArray) {
  89. var inner = anArray[i];
  90. if (this._arrayElementMatchesAll(inner)) {
  91. if (details && details.needRecord()) {
  92. details.setElemMatchKey(inner.fieldName());
  93. }
  94. return true;
  95. }
  96. }
  97. return false;
  98. };
  99. /**
  100. *
  101. * This documentation was automatically generated. Please update when you touch this function.
  102. * @method numChildren
  103. * @param
  104. *
  105. */
  106. proto.numChildren = function numChildren(){
  107. // File: expression_array.h lines: 102-101
  108. return this._subs.length;
  109. };
  110. /**
  111. *
  112. * This documentation was automatically generated. Please update when you touch this function.
  113. * @method shallowClone
  114. * @param
  115. *
  116. */
  117. proto.shallowClone = function shallowClone(){
  118. // File: expression_array.h lines: 91-97
  119. var element = new ElemMatchValueMatchExpression();
  120. element.init(this.path());
  121. for (var i = 0; i < this._subs.length; ++i) {
  122. element.add(this._subs[i].shallowClone());
  123. }
  124. return element;
  125. };