ElemMatchValueMatchExpression.js 3.3 KB

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