IndexKeyMatchableDocument.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. "use strict";
  2. // Autogenerated by cport.py on 2013-09-17 14:37
  3. var IndexKeyMatchableDocument = module.exports = function IndexKeyMatchableDocument(pattern, doc){
  4. this._pattern = pattern;
  5. this._doc = doc;
  6. }, klass = IndexKeyMatchableDocument, base = Object , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
  7. // File: matcher.cpp lines: 52-52
  8. proto._doc = undefined;
  9. // File: matcher.cpp lines: 51-51
  10. proto._pattern = undefined;
  11. // File: matcher.cpp lines: 52-52
  12. proto._doc = undefined;
  13. // File: matcher.cpp lines: 51-51
  14. proto._pattern = undefined;
  15. /**
  16. *
  17. * get the element at the input path
  18. * @method _getElement
  19. * @param path
  20. *
  21. */
  22. proto._getElement = function _getElement(path){
  23. // File: matcher.cpp lines: 63-77
  24. var patternElement, docElement;
  25. for (var i in this._pattern) {
  26. patternElement = this._pattern[i];
  27. //verify( docIterator.more() );
  28. if(i >= this._doc.length) throw new Error("Ran out of docs in IndexKeyMatchableDocument:35");
  29. docElement = this._doc[i];
  30. if (path.equalsDottedField(patternElement.fieldName())) {
  31. return docElement;
  32. }
  33. }
  34. return {};
  35. };
  36. /**
  37. *
  38. * This method returns a JSON representation of the Document
  39. * @method toBSON
  40. * @param
  41. *
  42. */
  43. proto.toJSON = function toJSON(){
  44. // File: matcher.cpp lines: 39-42
  45. // TODO: this isn't quite correct because of dots
  46. // don't think it'll ever be called though
  47. return this._doc.replaceFieldNames(this._pattern);
  48. };