UNPKG

forerunnerdb

Version:

A NoSQL document store database for browsers and Node.js.

46 lines 603 kB
<!doctype html> <html lang="en"> <head> <title>Code coverage report for lib/fdb-all.min.js</title> <meta charset="utf-8"> <link rel="stylesheet" href="../prettify.css"> <link rel="stylesheet" href="../base.css"> <style type='text/css'> div.coverage-summary .sorter { background-image: url(../sort-arrow-sprite.png); } </style> </head> <body> <div class="header medium"> <h1>Code coverage report for <span class="entity">lib/fdb-all.min.js</span></h1> <h2> Statements: <span class="metric">52.65% <small>(3092 / 5873)</small></span> &nbsp;&nbsp;&nbsp;&nbsp; Branches: <span class="metric">39.47% <small>(2299 / 5825)</small></span> &nbsp;&nbsp;&nbsp;&nbsp; Functions: <span class="metric">53.29% <small>(1092 / 2049)</small></span> &nbsp;&nbsp;&nbsp;&nbsp; Lines: <span class="metric">100% <small>(10 / 10)</small></span> &nbsp;&nbsp;&nbsp;&nbsp; Ignored: <span class="metric"><span class="ignore-none">none</span></span> &nbsp;&nbsp;&nbsp;&nbsp; </h2> <div class="path"><a href="../index.html">All files</a> &#187; <a href="index.html">lib/</a> &#187; fdb-all.min.js</div> </div> <div class="body"> <pre><table class="coverage"> <tr><td class="line-count">1 2 3 4 5 6 7 8 9 10</td><td class="line-coverage"><span class="cline-any cline-yes">134722</span> <span class="cline-any cline-yes">2048</span> <span class="cline-any cline-yes">165148</span> <span class="cline-any cline-yes">280218</span> <span class="cline-any cline-yes">390</span> <span class="cline-any cline-yes">1118</span> <span class="cline-any cline-yes">12198</span> <span class="cline-any cline-yes">70520</span> <span class="cline-any cline-yes">2939</span> <span class="cline-any cline-yes">878</span></td><td class="text"><pre class="prettyprint lang-js">!function a(b,c,d){function e(g,h){if(!c[g]){<span class="missing-if-branch" title="if path not taken" >I</span>if(!b[g]){<span class="cstat-no" title="statement not covered" >var i="function"==typeof require&amp;&amp;require;<span class="cstat-no" title="statement not covered" >i</span>f(!h&amp;&amp;i)<span class="cstat-no" title="statement not covered" >return i(g,!0);<span class="cstat-no" title="statement not covered" >i</span></span>f(f)<span class="cstat-no" title="statement not covered" >return f(g,!0);<span class="cstat-no" title="statement not covered" >v</span></span>ar j=new Error("Cannot find module '"+g+"'");<span class="cstat-no" title="statement not covered" >t</span>hrow j.code="MODULE_NOT_FOUND",j}</span>var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:<span class="branch-1 cbranch-no" title="branch not covered" >a)</span>},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&amp;&amp;require,g=0;g&lt;d.length;g++)e(d[g]);return e}({1:[function(a,b,c){var d=a("./core");a("../lib/CollectionGroup"),a("../lib/View"),a("../lib/Highchart"),a("../lib/Persist"),a("../lib/Document"),a("../lib/Overview"),a("../lib/Grid"),a("../lib/Rest"),a("../lib/Odm");"undefined"!=typeof window&amp;&amp;(window.ForerunnerDB=d),b.exports=d},{"../lib/CollectionGroup":6,"../lib/Document":10,"../lib/Grid":11,"../lib/Highchart":12,"../lib/Odm":26,"../lib/Overview":29,"../lib/Persist":31,"../lib/Rest":35,"../lib/View":39,"./core":2}],2:[function(a,b,c){var d=a("../lib/Core");a("../lib/Shim.IE8");"undefined"!=typeof window&amp;&amp;(window.ForerunnerDB=d),b.exports=d},{"../lib/Core":7,"../lib/Shim.IE8":38}],3:[function(a,b,c){"use strict";var d=a("./Shared"),e=function(a){var b;this._primaryKey="_id",this._keyArr=[],this._data=[],this._objLookup={},this._count=0;for(b in a)a.hasOwnProperty(b)&amp;&amp;this._keyArr.push({key:b,dir:a[b]})};d.addModule("ActiveBucket",e),d.mixin(e.prototype,"Mixin.Sorting"),d.synthesize(e.prototype,"primaryKey"),e.prototype.qs=function(a,b,c,d){if(!b.length)return 0;for(var e,f,g,h=-1,i=0,j=b.length-1;j&gt;=i&amp;&amp;(e=Math.floor((i+j)/2),h!==e);)f=b[e],void 0!==f&amp;&amp;(g=d(this,a,c,f),g&gt;0&amp;&amp;(i=e+1),0&gt;g&amp;&amp;(j=e-1)),h=e;return g&gt;0?e+1:e},e.prototype._sortFunc=function(a,b,c,d){var e,f,g,h=c.split(".:."),i=d.split(".:."),j=a._keyArr,k=j.length;for(e=0;k&gt;e;e++)if(f=j[e],g=typeof b[f.key],"number"===g&amp;&amp;(h[e]=Number(h[e]),i[e]=Number(i[e])),h[e]!==i[e]){if(1===f.dir)return a.sortAsc(h[e],i[e]);<span class="missing-if-branch" title="else path not taken" >E</span>if(-1===f.dir)return a.sortDesc(h[e],i[e])}},e.prototype.insert=function(a){var b,c;return b=this.documentKey(a),c=this._data.indexOf(b),-1===c?(c=this.qs(a,this._data,b,this._sortFunc),this._data.splice(c,0,b)):this._data.splice(c,0,b),this._objLookup[a[this._primaryKey]]=b,this._count++,c},e.prototype.remove=function(a){var b,c;return b=this._objLookup[a[this._primaryKey]],b?(c=this._data.indexOf(b),c&gt;-1?(this._data.splice(c,1),delete this._objLookup[a[this._primaryKey]],this._count--,!0):<span class="branch-1 cbranch-no" title="branch not covered" >!1)</span>:<span class="branch-1 cbranch-no" title="branch not covered" >!1}</span>,e.prototype.index=function(a){var b,c;return b=this.documentKey(a),c=this._data.indexOf(b),-1===c&amp;&amp;(<span class="branch-1 cbranch-no" title="branch not covered" >c=this.qs(a,this._data,b,this._sortFunc))</span>,c},e.prototype.documentKey=function(a){var b,c,d="",e=this._keyArr,f=e.length;for(b=0;f&gt;b;b++)c=e[b],d&amp;&amp;(d+=".:."),d+=a[c.key];return d+=".:."+a[this._primaryKey]},e.prototype.count=function(){return this._count},d.finishModule("ActiveBucket"),b.exports=e},{"./Shared":37}],4:[function(a,b,c){"use strict";var d=a("./Shared"),e=function(a,b,c){this.init.apply(this,arguments)};e.prototype.init=function(a,b,c,d){this._store=[],void 0!==b&amp;&amp;<span class="branch-1 cbranch-no" title="branch not covered" >this.index(b),</span>void 0!==c&amp;&amp;<span class="branch-1 cbranch-no" title="branch not covered" >this.compareFunc(c),</span>void 0!==d&amp;&amp;<span class="branch-1 cbranch-no" title="branch not covered" >this.hashFunc(d),</span>void 0!==a&amp;&amp;<span class="branch-1 cbranch-no" title="branch not covered" >this.data(a)}</span>,d.addModule("BinaryTree",e),d.mixin(e.prototype,"Mixin.ChainReactor"),d.mixin(e.prototype,"Mixin.Sorting"),d.mixin(e.prototype,"Mixin.Common"),d.synthesize(e.prototype,"compareFunc"),d.synthesize(e.prototype,"hashFunc"),d.synthesize(e.prototype,"indexDir"),d.synthesize(e.prototype,"index",<span class="fstat-no" title="function not covered" >function(a){<span class="cstat-no" title="statement not covered" ></span>return void 0!==a&amp;&amp;(a instanceof Array||(a=this.keys(a))),this.$super.call(this,a)}</span>),e.prototype.keys=<span class="fstat-no" title="function not covered" >function(a){<span class="cstat-no" title="statement not covered" ></span>var b,c=[];<span class="cstat-no" title="statement not covered" >f</span>or(b in a)<span class="cstat-no" title="statement not covered" >a.hasOwnProperty(b)&amp;&amp;c.push({key:b,val:a[b]});<span class="cstat-no" title="statement not covered" >r</span></span>eturn c}</span>,e.prototype.data=<span class="fstat-no" title="function not covered" >function(a){<span class="cstat-no" title="statement not covered" ></span>return void 0!==a?(this._data=a,this._hashFunc&amp;&amp;(this._hash=this._hashFunc(a)),this):this._data}</span>,e.prototype.push=<span class="fstat-no" title="function not covered" >function(a){<span class="cstat-no" title="statement not covered" ></span>return void 0!==a?(this._store.push(a),this):!1}</span>,e.prototype.pull=<span class="fstat-no" title="function not covered" >function(a){<span class="cstat-no" title="statement not covered" ></span>if(void 0!==a){<span class="cstat-no" title="statement not covered" >var b=this._store.indexOf(a);<span class="cstat-no" title="statement not covered" >i</span>f(b&gt;-1)<span class="cstat-no" title="statement not covered" >return this._store.splice(b,1),!0}<span class="cstat-no" title="statement not covered" ></span></span>r</span>eturn!1}</span>,e.prototype._compareFunc=<span class="fstat-no" title="function not covered" >function(a,b){<span class="cstat-no" title="statement not covered" ></span>var c,d,e=0;<span class="cstat-no" title="statement not covered" >f</span>or(c=0;c&lt;this._index.length;c++)<span class="cstat-no" title="statement not covered" >if(d=this._index[c],1===d.val?e=this.sortAsc(a[d.key],b[d.key]):-1===d.val&amp;&amp;(e=this.sortDesc(a[d.key],b[d.key])),0!==e)<span class="cstat-no" title="statement not covered" >return e;<span class="cstat-no" title="statement not covered" >r</span></span></span>eturn e}</span>,e.prototype._hashFunc=<span class="fstat-no" title="function not covered" >function(a){<span class="cstat-no" title="statement not covered" ></span>return a[this._index[0].key]}</span>,e.prototype.insert=<span class="fstat-no" title="function not covered" >function(a){<span class="cstat-no" title="statement not covered" ></span>var b,c,d,f;<span class="cstat-no" title="statement not covered" >i</span>f(a instanceof Array){<span class="cstat-no" title="statement not covered" >for(c=[],d=[],f=0;f&lt;a.length;f++)<span class="cstat-no" title="statement not covered" >this.insert(a[f])?c.push(a[f]):d.push(a[f]);<span class="cstat-no" title="statement not covered" >r</span></span>eturn{inserted:c,failed:d}}<span class="cstat-no" title="statement not covered" ></span>r</span>eturn this._data?(b=this._compareFunc(this._data,a),0===b?(this.push(a),this._left?this._left.insert(a):this._left=new e(a,this._index,this._compareFunc,this._hashFunc),!0):-1===b?(this._right?this._right.insert(a):this._right=new e(a,this._index,this._compareFunc,this._hashFunc),!0):1===b?(this._left?this._left.insert(a):this._left=new e(a,this._index,this._compareFunc,this._hashFunc),!0):!1):(this.data(a),!0)}</span>,e.prototype.lookup=<span class="fstat-no" title="function not covered" >function(a,b){<span class="cstat-no" title="statement not covered" ></span>var c=this._compareFunc(this._data,a);<span class="cstat-no" title="statement not covered" >r</span>eturn b=b||[],0===c&amp;&amp;(this._left&amp;&amp;this._left.lookup(a,b),b.push(this._data),this._right&amp;&amp;this._right.lookup(a,b)),-1===c&amp;&amp;this._right&amp;&amp;this._right.lookup(a,b),1===c&amp;&amp;this._left&amp;&amp;this._left.lookup(a,b),b}</span>,e.prototype.inOrder=function(a,b){switch(b=b||[],this._left&amp;&amp;<span class="branch-1 cbranch-no" title="branch not covered" >this._left.inOrder(a,b),</span>a){case"hash":b.push(this._hash);break;<span class="branch-1 cbranch-no" title="branch not covered" >case"key":<span class="cstat-no" title="statement not covered" >b.push(this._data);<span class="cstat-no" title="statement not covered" >b</span>reak;<span class="branch-2 cbranch-no" title="branch not covered" >d</span></span>efault:<span class="cstat-no" title="statement not covered" >b.push({key:this._key,arr:this._store})}</span></span>return this._right&amp;&amp;<span class="branch-1 cbranch-no" title="branch not covered" >this._right.inOrder(a,b),</span>b},d.finishModule("BinaryTree"),b.exports=e},{"./Shared":37}],5:[function(a,b,c){"use strict";var d,e,f,g,h,i,j,k,l,m;d=a("./Shared");var n=function(a){this.init.apply(this,arguments)};n.prototype.init=function(a,b){this._primaryKey="_id",this._primaryIndex=new g("primary"),this._primaryCrc=new g("primaryCrc"),this._crcLookup=new g("crcLookup"),this._name=a,this._data=[],this._metrics=new f,this._options=b||{changeTimestamp:!1},this._metaData={},this._deferQueue={insert:[],update:[],remove:[],upsert:[]},this._deferThreshold={insert:100,update:100,remove:100,upsert:100},this._deferTime={insert:1,update:1,remove:1,upsert:1},this.subsetOf(this)},d.addModule("Collection",n),d.mixin(n.prototype,"Mixin.Common"),d.mixin(n.prototype,"Mixin.Events"),d.mixin(n.prototype,"Mixin.ChainReactor"),d.mixin(n.prototype,"Mixin.CRUD"),d.mixin(n.prototype,"Mixin.Constants"),d.mixin(n.prototype,"Mixin.Triggers"),d.mixin(n.prototype,"Mixin.Sorting"),d.mixin(n.prototype,"Mixin.Matching"),d.mixin(n.prototype,"Mixin.Updating"),f=a("./Metrics"),g=a("./KeyValueStore"),h=a("./Path"),i=a("./IndexHashMap"),j=a("./IndexBinaryTree"),k=a("./Crc"),e=d.modules.Db,l=a("./Overload"),m=a("./ReactorIO"),n.prototype.crc=k,d.synthesize(n.prototype,"state"),d.synthesize(n.prototype,"name"),d.synthesize(n.prototype,"metaData"),n.prototype.data=function(){return this._data},n.prototype.drop=function(a){var b;<span class="missing-if-branch" title="if path not taken" >I</span>if(this.isDropped())<span class="cstat-no" title="statement not covered" >return a&amp;&amp;a(!1,!0),!0;<span class="missing-if-branch" title="else path not taken" >E</span>i</span>f(this._db&amp;&amp;this._db._collection&amp;&amp;this._name){if(this.debug()&amp;&amp;console.log(this.logIdentifier()+" Dropping"),this._state="dropped",this.emit("drop",this),delete this._db._collection[this._name],this._collate)for(b in this._collate)this._collate.hasOwnProperty(b)&amp;&amp;this.collateRemove(b);return delete this._primaryKey,delete this._primaryIndex,delete this._primaryCrc,delete this._crcLookup,delete this._name,delete this._data,delete this._metrics,a&amp;&amp;<span class="branch-1 cbranch-no" title="branch not covered" >a(!1,!0),</span>!0}<span class="cstat-no" title="statement not covered" >return a&amp;&amp;a(!1,!0),!1}</span>,n.prototype.primaryKey=function(a){return void 0!==a?(this._primaryKey!==a&amp;&amp;(this._primaryKey=a,this._primaryIndex.primaryKey(a),this.rebuildPrimaryKeyIndex()),this):this._primaryKey},n.prototype._onInsert=function(a,b){this.emit("insert",a,b)},n.prototype._onUpdate=function(a){this.emit("update",a)},n.prototype._onRemove=function(a){this.emit("remove",a)},n.prototype._onChange=function(){this._options.changeTimestamp&amp;&amp;(this._metaData.lastChange=new Date)},d.synthesize(n.prototype,"db",function(a){return a&amp;&amp;"_id"===this.primaryKey()&amp;&amp;(this.primaryKey(a.primaryKey()),this.debug(a.debug())),this.$super.apply(this,arguments)}),d.synthesize(n.prototype,"mongoEmulation"),n.prototype.setData=function(a,b,c){<span class="missing-if-branch" title="if path not taken" >I</span>if(this.isDropped())<span class="cstat-no" title="statement not covered" >throw this.logIdentifier()+" Cannot operate in a dropped state!";<span class="missing-if-branch" title="else path not taken" >E</span>i</span>f(a){var d=this._metrics.create("setData");d.start(),b=this.options(b),this.preSetData(a,b,c),b.$decouple&amp;&amp;(a=this.decouple(a)),a instanceof Array||(a=[a]),d.time("transformIn"),a=this.transformIn(a),d.time("transformIn");var e=[].concat(this._data);this._dataReplace(a),d.time("Rebuild Primary Key Index"),this.rebuildPrimaryKeyIndex(b),d.time("Rebuild Primary Key Index"),d.time("Rebuild All Other Indexes"),this._rebuildIndexes(),d.time("Rebuild All Other Indexes"),d.time("Resolve chains"),this.chainSend("setData",a,{oldData:e}),d.time("Resolve chains"),d.stop(),this._onChange(),this.emit("setData",this._data,e)}return c&amp;&amp;<span class="branch-1 cbranch-no" title="branch not covered" >c(!1),</span>this},n.prototype.rebuildPrimaryKeyIndex=function(a){a=a||{$ensureKeys:void 0,$violationCheck:void 0};var b,c,d,e,f=a&amp;&amp;void 0!==a.$ensureKeys?<span class="branch-0 cbranch-no" title="branch not covered" >a.$ensureKeys:</span>!0,g=a&amp;&amp;void 0!==a.$violationCheck?<span class="branch-0 cbranch-no" title="branch not covered" >a.$violationCheck:</span>!0,h=this._primaryIndex,i=this._primaryCrc,j=this._crcLookup,k=this._primaryKey;for(h.truncate(),i.truncate(),j.truncate(),b=this._data,c=b.length;c--;){<span class="missing-if-branch" title="else path not taken" >E</span>if(d=b[c],f&amp;&amp;this.ensurePrimaryKey(d),g){<span class="missing-if-branch" title="if path not taken" >I</span>if(!h.uniqueSet(d[k],d))<span class="cstat-no" title="statement not covered" >throw this.logIdentifier()+" Call to setData on collection failed because your data violates the primary key unique constraint. One or more documents are using the same primary key: "+d[this._primaryKey]}</span>else <span class="cstat-no" title="statement not covered" >h.set(d[k],d);e</span>=this.jStringify(d),i.set(d[k],e),j.set(e,d)}},n.prototype.ensurePrimaryKey=function(a){void 0===a[this._primaryKey]&amp;&amp;(a[this._primaryKey]=this.objectId())},n.prototype.truncate=function(){<span class="missing-if-branch" title="if path not taken" >I</span>if(this.isDropped())<span class="cstat-no" title="statement not covered" >throw this.logIdentifier()+" Cannot operate in a dropped state!";r</span>eturn this.emit("truncate",this._data),this._data.length=0,this._primaryIndex=new g("primary"),this._primaryCrc=new g("primaryCrc"),this._crcLookup=new g("crcLookup"),this._onChange(),this.deferEmit("change",{type:"truncate"}),this},n.prototype.upsert=function(a,b){<span class="missing-if-branch" title="if path not taken" >I</span>if(this.isDropped())<span class="cstat-no" title="statement not covered" >throw this.logIdentifier()+" Cannot operate in a dropped state!";<span class="missing-if-branch" title="else path not taken" >E</span>i</span>f(a){var c,d,e=this._deferQueue.upsert,f=this._deferThreshold.upsert,g={};if(a instanceof Array){<span class="missing-if-branch" title="if path not taken" >I</span>if(a.length&gt;f)<span class="cstat-no" title="statement not covered" >return this._deferQueue.upsert=e.concat(a),this.processQueue("upsert",b),{};f</span>or(g=[],d=0;d&lt;a.length;d++)g.push(this.upsert(a[d]));return b&amp;&amp;<span class="branch-1 cbranch-no" title="branch not covered" >b(),</span>g}switch(a[this._primaryKey]?(c={},c[this._primaryKey]=a[this._primaryKey],this._primaryIndex.lookup(c)[0]?g.op="update":g.op="insert"):<span class="branch-1 cbranch-no" title="branch not covered" >g.op="insert",</span>g.op){case"insert":g.result=this.insert(a);break;case"update":g.result=this.update(c,a)}return g}<span class="cstat-no" title="statement not covered" >return b&amp;&amp;b(),{}}</span>,n.prototype.filter=function(a,b,c){return this.find(a,c).filter(b)},n.prototype.filterUpdate=function(a,b,c){var d,e,f,g,h=this.find(a,c),i=[],j=this.primaryKey();for(g=0;g&lt;h.length;g++)d=h[g],f=b(d),f&amp;&amp;(e={},e[j]=d[j],i.push(this.update(e,f)));return i},n.prototype.update=function(a,b,c){<span class="missing-if-branch" title="if path not taken" >I</span>if(this.isDropped())<span class="cstat-no" title="statement not covered" >throw this.logIdentifier()+" Cannot operate in a dropped state!";b</span>=this.decouple(b),this.mongoEmulation()&amp;&amp;(this.convertToFdb(a),this.convertToFdb(b)),b=this.transformIn(b),this.debug()&amp;&amp;console.log(this.logIdentifier()+" Updating some data");var d,e,f=this,g=this._metrics.create("update"),h=function(d){var e,h,i,j=f.decouple(d);return f.willTrigger(f.TYPE_UPDATE,f.PHASE_BEFORE)||f.willTrigger(f.TYPE_UPDATE,f.PHASE_AFTER)?(e=f.decouple(d),h={type:"update",query:f.decouple(a),update:f.decouple(b),options:f.decouple(c),op:g},i=f.updateObject(e,h.update,h.query,h.options,""),f.processTrigger(h,f.TYPE_UPDATE,f.PHASE_BEFORE,d,e)!==!1?(i=f.updateObject(d,e,h.query,h.options,""),f.processTrigger(h,f.TYPE_UPDATE,f.PHASE_AFTER,j,e)):i=!1):i=f.updateObject(d,b,a,c,""),f._updateIndexes(j,d),i};return g.start(),g.time("Retrieve documents to update"),d=this.find(a,{$decouple:!1}),g.time("Retrieve documents to update"),d.length&amp;&amp;(g.time("Update documents"),e=d.filter(h),g.time("Update documents"),e.length&amp;&amp;(g.time("Resolve chains"),this.chainSend("update",{query:a,update:b,dataSet:d},c),g.time("Resolve chains"),this._onUpdate(e),this._onChange(),this.deferEmit("change",{type:"update",data:e}))),g.stop(),e||<span class="branch-1 cbranch-no" title="branch not covered" >[]}</span>,n.prototype._replaceObj=<span class="fstat-no" title="function not covered" >function(a,b){<span class="cstat-no" title="statement not covered" ></span>var c;<span class="cstat-no" title="statement not covered" >t</span>his._removeFromIndexes(a);<span class="cstat-no" title="statement not covered" >f</span>or(c in a)<span class="cstat-no" title="statement not covered" >a.hasOwnProperty(c)&amp;&amp;delete a[c];<span class="cstat-no" title="statement not covered" >f</span></span>or(c in b)<span class="cstat-no" title="statement not covered" >b.hasOwnProperty(c)&amp;&amp;(a[c]=b[c]);<span class="cstat-no" title="statement not covered" >i</span></span>f(!this._insertIntoIndexes(a))<span class="cstat-no" title="statement not covered" >throw this.logIdentifier()+" Primary key violation in update! Key violated: "+a[this._primaryKey];<span class="cstat-no" title="statement not covered" >r</span></span>eturn this}</span>,n.prototype.updateById=function(a,b){var c={};return c[this._primaryKey]=a,this.update(c,b)},n.prototype.updateObject=function(a,b,c,d,e,f){b=this.decouple(b),e=e||"","."===e.substr(0,1)&amp;&amp;(e=e.substr(1,e.length-1));var g,i,j,k,l,m,n,o,p,q=!1,r=!1;for(p in b)<span class="missing-if-branch" title="else path not taken" >E</span>if(b.hasOwnProperty(p)){if(g=!1,"$"===p.substr(0,1))switch(p){<span class="branch-0 cbranch-no" title="branch not covered" >case"$key":<span class="branch-1 cbranch-no" title="branch not covered" >c</span>ase"$index":c</span>ase"$data":case"$min":case"$max":g=!0;break;case"$each":for(g=!0,k=b.$each.length,j=0;k&gt;j;j++)r=this.updateObject(a,b.$each[j],c,d,e),r&amp;&amp;(q=!0);q=q||<span class="branch-1 cbranch-no" title="branch not covered" >r;</span>break;default:g=!0,r=this.updateObject(a,b[p],c,d,e,p),q=q||r}if(this._isPositionalKey(p)&amp;&amp;(g=!0,p=p.substr(0,p.length-2),m=new h(e+"."+p),a[p]&amp;&amp;a[p]instanceof Array&amp;&amp;a[p].length)){for(i=[],j=0;j&lt;a[p].length;j++)this._match(a[p][j],m.value(c)[0],d,"",{})&amp;&amp;i.push(j);for(j=0;j&lt;i.length;j++)r=this.updateObject(a[p][i[j]],b[p+".$"],c,d,e+"."+p,f),q=q||r}if(!g)if(f||"object"!=typeof b[p])switch(f){case"$inc":var s=!0;b[p]&gt;0?b.$max&amp;&amp;<span class="branch-1 cbranch-no" title="branch not covered" >a[p]&gt;=b.$max&amp;</span>&amp;(<span class="branch-2 cbranch-no" title="branch not covered" >s=!1)</span>:b[p]&lt;0&amp;&amp;b.$min&amp;&amp;<span class="branch-2 cbranch-no" title="branch not covered" >a[p]&lt;=b.$min&amp;</span>&amp;(<span class="branch-3 cbranch-no" title="branch not covered" >s=!1)</span>,s&amp;&amp;(this._updateIncrement(a,p,b[p]),q=!0);break;case"$cast":switch(b[p]){case"array":a[p]instanceof Array||(this._updateProperty(a,p,b.$data||[]),q=!0);break;<span class="branch-1 cbranch-no" title="branch not covered" >case"object":<span class="cstat-no" title="statement not covered" >(!(a[p]instanceof Object)||a[p]instanceof Array)&amp;&amp;(this._updateProperty(a,p,b.$data||{}),q=!0);<span class="cstat-no" title="statement not covered" >b</span>reak;<span class="branch-2 cbranch-no" title="branch not covered" >c</span></span>ase"number":<span class="cstat-no" title="statement not covered" >"number"!=typeof a[p]&amp;&amp;(this._updateProperty(a,p,Number(a[p])),q=!0);<span class="cstat-no" title="statement not covered" >b</span>reak;<span class="branch-3 cbranch-no" title="branch not covered" >c</span></span>ase"string":<span class="cstat-no" title="statement not covered" >"string"!=typeof a[p]&amp;&amp;(this._updateProperty(a,p,String(a[p])),q=!0);<span class="cstat-no" title="statement not covered" >b</span>reak;<span class="branch-4 cbranch-no" title="branch not covered" >d</span></span>efault:<span class="cstat-no" title="statement not covered" >throw this.logIdentifier()+" Cannot update cast to unknown type: "+b[p]}</span></span>break;case"$push":<span class="missing-if-branch" title="if path not taken" >I</span>if(void 0===a[p]&amp;&amp;this._updateProperty(a,p,[]),!(a[p]instanceof Array))<span class="cstat-no" title="statement not covered" >throw this.logIdentifier()+" Cannot push to a key that is not an array! ("+p+")";i</span>f(void 0!==b[p].$position&amp;&amp;b[p].$each instanceof Array)for(l=b[p].$position,k=b[p].$each.length,j=0;k&gt;j;j++)this._updateSplicePush(a[p],l+j,b[p].$each[j]);else if(b[p].$each instanceof Array)for(k=b[p].$each.length,j=0;k&gt;j;j++)this._updatePush(a[p],b[p].$each[j]);else this._updatePush(a[p],b[p]);q=!0;break;case"$pull":<span class="missing-if-branch" title="else path not taken" >E</span>if(a[p]instanceof Array){for(i=[],j=0;j&lt;a[p].length;j++)this._match(a[p][j],b[p],d,"",{})&amp;&amp;i.push(j);for(k=i.length;k--;)this._updatePull(a[p],i[k]),q=!0}break;case"$pullAll":<span class="missing-if-branch" title="else path not taken" >E</span>if(a[p]instanceof Array){<span class="missing-if-branch" title="if path not taken" >I</span>if(!(b[p]instanceof Array))<span class="cstat-no" title="statement not covered" >throw this.logIdentifier()+" Cannot pullAll without being given an array of values to pull! ("+p+")";<span class="missing-if-branch" title="else path not taken" >E</span>i</span>f(i=a[p],k=i.length,k&gt;0)for(;k--;){for(l=0;l&lt;b[p].length;l++)i[k]===b[p][l]&amp;&amp;(this._updatePull(a[p],k),k--,q=!0);if(0&gt;k)break}}break;case"$addToSet":<span class="missing-if-branch" title="if path not taken" >I</span>if(void 0===a[p]&amp;&amp;<span class="branch-1 cbranch-no" title="branch not covered" >this._updateProperty(a,p,[]),</span>!(a[p]instanceof Array))<span class="cstat-no" title="statement not covered" >throw this.logIdentifier()+" Cannot addToSet on a key that is not an array! ("+p+")";v</span>ar t,u,v,w,x=a[p],y=x.length,z=!0,A=d&amp;&amp;d.$addToSet;for(b[p].$key?(v=!1,w=new h(b[p].$key),u=w.value(b[p])[0],delete b[p].$key):A&amp;&amp;A.key?(v=!1,w=new h(A.key),u=w.value(b[p])[0]):(u=this.jStringify(b[p]),v=!0),t=0;y&gt;t;t++)if(v){<span class="missing-if-branch" title="else path not taken" >E</span>if(this.jStringify(x[t])===u){z=!1;break}}else if(u===w.value(x[t])[0]){z=!1;break}z&amp;&amp;(this._updatePush(a[p],b[p]),q=!0);break;case"$splicePush":<span class="missing-if-branch" title="if path not taken" >I</span>if(void 0===a[p]&amp;&amp;<span class="branch-1 cbranch-no" title="branch not covered" >this._updateProperty(a,p,[]),</span>!(a[p]instanceof Array))<span class="cstat-no" title="statement not covered" >throw this.logIdentifier()+" Cannot splicePush with a key that is not an array! ("+p+")";<span class="missing-if-branch" title="if path not taken" >I</span>i</span>f(l=b.$index,void 0===l)<span class="cstat-no" title="statement not covered" >throw this.logIdentifier()+" Cannot splicePush without a $index integer value!";d</span>elete b.$index,l&gt;a[p].length&amp;&amp;(<span class="branch-1 cbranch-no" title="branch not covered" >l=a[p].length)</span>,this._updateSplicePush(a[p],l,b[p]),q=!0;break;case"$move":<span class="missing-if-branch" title="if path not taken" >I</span>if(!(a[p]instanceof Array))<span class="cstat-no" title="statement not covered" >throw this.logIdentifier()+" Cannot move on a key that is not an array! ("+p+")";f</span>or(j=0;j&lt;a[p].length;j++)<span class="missing-if-branch" title="else path not taken" >E</span>if(this._match(a[p][j],b[p],d,"",{})){var B=b.$index;<span class="missing-if-branch" title="if path not taken" >I</span>if(void 0===B)<span class="cstat-no" title="statement not covered" >throw this.logIdentifier()+" Cannot move without a $index integer value!";d</span>elete b.$index,this._updateSpliceMove(a[p],j,B),q=!0;break}break;case"$mul":this._updateMultiply(a,p,b[p]),q=!0;break;case"$rename":this._updateRename(a,p,b[p]),q=!0;break;case"$overwrite":this._updateOverwrite(a,p,b[p]),q=!0;break;case"$unset":this._updateUnset(a,p),q=!0;break;<span class="branch-12 cbranch-no" title="branch not covered" >case"$clear":<span class="cstat-no" title="statement not covered" >this._updateClear(a,p),q=!0;<span class="cstat-no" title="statement not covered" >b</span>reak;<span class="branch-13 cbranch-no" title="branch not covered" >c</span></span>ase"$pop":<span class="cstat-no" title="statement not covered" >if(!(a[p]instanceof Array))<span class="cstat-no" title="statement not covered" >throw this.logIdentifier()+" Cannot pop from a key that is not an array! ("+p+")";<span class="cstat-no" title="statement not covered" >t</span></span>his._updatePop(a[p],b[p])&amp;&amp;(q=!0);<span class="cstat-no" title="statement not covered" >b</span>reak;c</span></span>ase"$toggle":this._updateProperty(a,p,!a[p]),q=!0;break;default:a[p]!==b[p]&amp;&amp;(this._updateProperty(a,p,b[p]),q=!0)}else <span class="missing-if-branch" title="else path not taken" >E</span>if(null!==a[p]&amp;&amp;"object"==typeof a[p])if(n=a[p]instanceof Array,o=b[p]instanceof Array,n||o)if(!o&amp;&amp;n)for(j=0;j&lt;a[p].length;j++)r=this.updateObject(a[p][j],b[p],c,d,e+"."+p,f),q=q||r;else a[p]!==b[p]&amp;&amp;(this._updateProperty(a,p,b[p]),q=!0);else r=this.updateObject(a[p],b[p],c,d,e+"."+p,f),q=q||r;else <span class="cstat-no" title="statement not covered" >a[p]!==b[p]&amp;&amp;(this._updateProperty(a,p,b[p]),q=!0)}</span>return q},n.prototype._isPositionalKey=function(a){return".$"===a.substr(a.length-2,2)},n.prototype.remove=function(a,b,c){<span class="missing-if-branch" title="if path not taken" >I</span>if(this.isDropped())<span class="cstat-no" title="statement not covered" >throw this.logIdentifier()+" Cannot operate in a dropped state!";v</span>ar d,e,f,g,h,i,j,k,l=this;if("function"==typeof b&amp;&amp;(<span class="branch-1 cbranch-no" title="branch not covered" >c=b,b={})</span>,this.mongoEmulation()&amp;&amp;<span class="branch-1 cbranch-no" title="branch not covered" >this.convertToFdb(a),</span>a instanceof Array){for(g=[],f=0;f&lt;a.length;f++)<span class="cstat-no" title="statement not covered" >g.push(this.remove(a[f],{noEmit:!0}));r</span>eturn(!b||<span class="branch-1 cbranch-no" title="branch not covered" >b&amp;</span>&amp;<span class="branch-2 cbranch-no" title="branch not covered" >!b.noEmit)</span>&amp;&amp;this._onRemove(g),c&amp;&amp;<span class="branch-1 cbranch-no" title="branch not covered" >c(!1,g),</span>g}<span class="missing-if-branch" title="else path not taken" >E</span>if(d=this.find(a,{$decouple:!1}),d.length){h=function(a){l._removeFromIndexes(a),e=l._data.indexOf(a),l._dataRemoveAtIndex(e)};for(var m=0;m&lt;d.length;m++)j=d[m],l.willTrigger(l.TYPE_REMOVE,l.PHASE_BEFORE)||l.willTrigger(l.TYPE_REMOVE,l.PHASE_AFTER)?(i={type:"remove"},k=l.decouple(j),l.processTrigger(i,l.TYPE_REMOVE,l.PHASE_BEFORE,k,k)!==!1&amp;&amp;(h(j),l.processTrigger(i,l.TYPE_REMOVE,l.PHASE_AFTER,k,k))):h(j);this.chainSend("remove",{query:a,dataSet:d},b),(!b||<span class="branch-1 cbranch-no" title="branch not covered" >b&amp;</span>&amp;<span class="branch-2 cbranch-no" title="branch not covered" >!b.noEmit)</span>&amp;&amp;this._onRemove(d),this._onChange(),this.deferEmit("change",{type:"remove",data:d})}return c&amp;&amp;<span class="branch-1 cbranch-no" title="branch not covered" >c(!1,d),</span>d},n.prototype.removeById=function(a){var b={};return b[this._primaryKey]=a,this.remove(b)},n.prototype.processQueue=function(a,b,c){var d,e,f=this,g=this._deferQueue[a],h=this._deferThreshold[a],i=this._deferTime[a];if(c=c||{deferred:!0},g.length){<span class="missing-if-branch" title="else path not taken" >E</span>if(g.length)switch(d=g.length&gt;h?g.splice(0,h):g.splice(0,g.length),e=f[a](d),a){case"insert":c.inserted=c.inserted||[],c.failed=c.failed||[],c.inserted=c.inserted.concat(e.inserted),c.failed=c.failed.concat(e.failed)}setTimeout(function(){f.processQueue.call(f,a,b,c)},i)}else b&amp;&amp;b(c);this.isProcessingQueue()||this.emit("queuesComplete")},n.prototype.isProcessingQueue=function(){var a;for(a in this._deferQueue)if(this._deferQueue.hasOwnProperty(a)&amp;&amp;this._deferQueue[a].length)return!0;return!1},n.prototype.insert=function(a,b,c){<span class="missing-if-branch" title="if path not taken" >I</span>if(this.isDropped())<span class="cstat-no" title="statement not covered" >throw this.logIdentifier()+" Cannot operate in a dropped state!";r</span>eturn"function"==typeof b?(<span class="branch-0 cbranch-no" title="branch not covered" >c=b,b=this._data.length)</span>:void 0===b&amp;&amp;(b=this._data.length),a=this.transformIn(a),this._insertHandle(a,b,c)},n.prototype._insertHandle=function(a,b,c){var d,e,f,g=this._deferQueue.insert,h=this._deferThreshold.insert,i=[],j=[];if(a instanceof Array){if(a.length&gt;h)return this._deferQueue.insert=g.concat(a),void this.processQueue("insert",c);for(f=0;f&lt;a.length;f++)d=this._insert(a[f],b+f),d===!0?i.push(a[f]):j.push({doc:a[f],reason:d})}else d=this._insert(a,b),d===!0?i.push(a):j.push({doc:a,reason:d});return this.chainSend("insert",a,{index:b}),e={deferred:!1,inserted:i,failed:j},this._onInsert(i,j),c&amp;&amp;<span class="branch-1 cbranch-no" title="branch not covered" >c(e),</span>this._onChange(),this.deferEmit("change",{type:"insert",data:i}),e},n.prototype._insert=function(a,b){<span class="missing-if-branch" title="else path not taken" >E</span>if(a){var c,d,e,f,g=this;if(this.ensurePrimaryKey(a),c=this.insertIndexViolation(a),e=function(a){g._insertIntoIndexes(a),b&gt;g._data.length&amp;&amp;(b=g._data.length),g._dataInsertAtIndex(b,a)},c)return"Index violation in index: "+c;if(g.willTrigger(g.TYPE_INSERT,g.PHASE_BEFORE)||g.willTrigger(g.TYPE_INSERT,g.PHASE_AFTER)){if(d={type:"insert"},g.processTrigger(d,g.TYPE_INSERT,g.PHASE_BEFORE,{},a)===!1)return!1;e(a),g.willTrigger(g.TYPE_INSERT,g.PHASE_AFTER)&amp;&amp;(f=g.decouple(a),g.processTrigger(d,g.TYPE_INSERT,g.PHASE_AFTER,{},f))}else e(a);return!0}<span class="cstat-no" title="statement not covered" >return"No document passed to insert"}</span>,n.prototype._dataInsertAtIndex=function(a,b){this._data.splice(a,0,b)},n.prototype._dataRemoveAtIndex=function(a){this._data.splice(a,1)},n.prototype._dataReplace=function(a){for(;this._data.length;)this._data.pop();this._data=this._data.concat(a)},n.prototype._insertIntoIndexes=function(a){var b,c,d=this._indexByName,e=this.jStringify(a);c=this._primaryIndex.uniqueSet(a[this._primaryKey],a),this._primaryCrc.uniqueSet(a[this._primaryKey],e),this._crcLookup.uniqueSet(e,a);for(b in d)d.hasOwnProperty(b)&amp;&amp;d[b].insert(a);return c},n.prototype._removeFromIndexes=function(a){var b,c=this._indexByName,d=this.jStringify(a);this._primaryIndex.unSet(a[this._primaryKey]),this._primaryCrc.unSet(a[this._primaryKey]),this._crcLookup.unSet(d);for(b in c)c.hasOwnProperty(b)&amp;&amp;c[b].remove(a)},n.prototype._updateIndexes=function(a,b){this._removeFromIndexes(a),this._insertIntoIndexes(b)},n.prototype._rebuildIndexes=function(){var a,b=this._indexByName;for(a in b)b.hasOwnProperty(a)&amp;&amp;b[a].rebuild()},n.prototype.subset=function(a,b){var c=this.find(a,b);return(new n).subsetOf(this).primaryKey(this._primaryKey).setData(c)},d.synthesize(n.prototype,"subsetOf"),n.prototype.isSubsetOf=function(a){return this._subsetOf===a},n.prototype.distinct=function(a,b,c){<span class="missing-if-branch" title="if path not taken" >I</span>if(this.isDropped())<span class="cstat-no" title="statement not covered" >throw this.logIdentifier()+" Cannot operate in a dropped state!";v</span>ar d,e,f=this.find(b,c),g=new h(a),i={},j=[];for(e=0;e&lt;f.length;e++)d=g.value(f[e])[0],d&amp;&amp;!i[d]&amp;&amp;(i[d]=!0,j.push(d));return j},n.prototype.findById=function(a,b){var c={};return c[this._primaryKey]=a,this.find(c,b)[0]},n.prototype.peek=function(a,b){var c,d,e=this._data,f=e.length,g=new n,h=typeof a;<span class="missing-if-branch" title="else path not taken" >E</span>if("string"===h){for(c=0;f&gt;c;c++)d=this.jStringify(e[c]),d.indexOf(a)&gt;-1&amp;&amp;g.insert(e[c]);return g.find({},b)}<span class="cstat-no" title="statement not covered" >return this.find(a,b)}</span>,n.prototype.explain=function(a,b){var c=this.find(a,b);return c.__fdbOp._data},n.prototype.options=function(a){return a=a||{},a.$decouple=void 0!==a.$decouple?a.$decouple:!0,a.$explain=void 0!==a.$explain?a.$explain:!1,a},n.prototype.find=function(a,b,c){return this.mongoEmulation()&amp;&amp;this.convertToFdb(a),c?(<span class="branch-0 cbranch-no" title="branch not covered" >c("Callbacks for the find() operation are not yet implemented!",[]),[])</span>:this._find.apply(this,arguments)},n.prototype._find=function(a,b){<span class="missing-if-branch" title="if path not taken" >I</span>if(this.isDropped())<span class="cstat-no" title="statement not covered" >throw this.logIdentifier()+" Cannot operate in a dropped state!";a</span>=a||{},b=this.options(b);var c,d,e,f,g,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H=this._metrics.create("find"),I=this.primaryKey(),J=this,K=!0,L={},M=[],N=[],O=[],P={},Q={},R=function(c){return J._match(c,a,b,"and",P)};<span class="missing-if-branch" title="else path not taken" >E</span>if(H.start(),a){if(H.time("analyseQuery"),c=this._analyseQuery(J.decouple(a),b,H),H.time("analyseQuery"),H.data("analysis",c),c.hasJoin&amp;&amp;c.queriesJoin){for(H.time("joinReferences"),g=0;g&lt;c.joinsOn.length;g++)k=c.joinsOn[g],j=new h(c.joinQueries[k]),i=j.value(a)[0],L[c.joinsOn[g]]=this._db.collection(c.joinsOn[g]).subset(i),delete a[c.joinQueries[k]];H.time("joinReferences")}if(c.indexMatch.length&amp;&amp;(!b||b&amp;&amp;!b.$skipIndex)?(H.data("index.potential",c.indexMatch),H.data("index.used",c.indexMatch[0].index),H.time("indexLookup"),e=c.indexMatch[0].lookup||<span class="branch-1 cbranch-no" title="branch not covered" >[],</span>H.time("indexLookup"),c.indexMatch[0].keyData.totalKeyCount===c.indexMatch[0].keyData.score&amp;&amp;(K=!1)):H.flag("usedIndex",!1),K&amp;&amp;(e&amp;&amp;e.length?(d=e.length,H.time("tableScan: "+d),e=e.filter(R)):(d=this._data.length,H.time("tableScan: "+d),e=this._data.filter(R)),H.time("tableScan: "+d)),b.$orderBy&amp;&amp;(H.time("sort"),e=this.sort(b.$orderBy,e),H.time("sort")),void 0!==b.$page&amp;&amp;void 0!==b.$limit&amp;&amp;(Q.page=b.$page,Q.pages=Math.ceil(e.length/b.$limit),Q.records=e.length,b.$page&amp;&amp;b.$limit&gt;0&amp;&amp;(H.data("cursor",Q),e.splice(0,b.$page*b.$limit))),b.$skip&amp;&amp;(Q.skip=b.$skip,e.splice(0,b.$skip),H.data("skip",b.$skip)),b.$limit&amp;&amp;e&amp;&amp;e.length&gt;b.$limit&amp;&amp;(Q.limit=b.$limit,e.length=b.$limit,H.data("limit",b.$limit)),b.$decouple&amp;&amp;(H.time("decouple"),e=this.decouple(e),H.time("decouple"),H.data("flag.decouple",!0)),b.$join){for(f=0;f&lt;b.$join.length;f++)for(k in b.$join[f])<span class="missing-if-branch" title="else path not taken" >E</span>if(b.$join[f].hasOwnProperty(k))for(w=k,l=L[k]?L[k]:this._db.collection(k),m=b.$join[f][k],x=0;x&lt;e.length;x++){o={},q=!1,r=!1,v="";for(n in m)<span class="missing-if-branch" title="else path not taken" >E</span>if(m.hasOwnProperty(n))if("$"===n.substr(0,1))switch(n){case"$where":m[n].query&amp;&amp;(<span class="branch-1 cbranch-no" title="branch not covered" >o=m[n].query)</span>,m[n].options&amp;&amp;(p=m[n].options);break;case"$as":w=m[n];break;case"$multi":q=m[n];break;case"$require":r=m[n];break;case"$prefix":v=m[n]}else o[n]=J._resolveDynamicQuery(m[n],e[x]);if(s=l.find(o,p),!r||r&amp;&amp;s[0])if("$root"===w){<span class="missing-if-branch" title="if path not taken" >I</span>if(q!==!1)<span class="cstat-no" title="statement not covered" >throw this.logIdentifier()+' Cannot combine [$as: "$root"] with [$joinMulti: true] in $join clause!';t</span>=s[0],u=e[x];for(C in t)t.hasOwnProperty(C)&amp;&amp;void 0===u[v+C]&amp;&amp;(u[v+C]=t[C])}else e[x][w]=q===!1?s[0]:s;else M.push(e[x])}H.data("flag.join",!0)}if(M.length){for(H.time("removalQueue"),z=0;z&lt;M.length;z++)y=e.indexOf(M[z]),y&gt;-1&amp;&amp;e.splice(y,1);H.time("removalQueue")}if(b.$transform){for(H.time("transform"),z=0;z&lt;e.length;z++)e.splice(z,1,b.$transform(e[z]));H.time("transform"),H.data("flag.transform",!0)}this._transformEnabled&amp;&amp;this._transformOut&amp;&amp;(H.time("transformOut"),e=this.transformOut(e),H.time("transformOut")),H.data("results",e.length)}else <span class="cstat-no" title="statement not covered" >e=[];H</span>.time("scanFields");for(z in b)b.hasOwnProperty(z)&amp;&amp;0!==z.indexOf("$")&amp;&amp;(1===b[z]?N.push(z):0===b[z]&amp;&amp;O.push(z));if(H.time("scanFields"),N.length||O.length){for(H.data("flag.limitFields",!0),H.data("limitFields.on",N),H.data("limitFields.off",O),H.time("limitFields"),z=0;z&lt;e.length;z++){G=e[z];for(A in G)G.hasOwnProperty(A)&amp;&amp;(N.length&amp;&amp;A!==I&amp;&amp;-1===N.indexOf(A)&amp;&amp;delete G[A],O.length&amp;&amp;O.indexOf(A)&gt;-1&amp;&amp;delete G[A])}H.time("limitFields")}if(b.$elemMatch){H.data("flag.elemMatch",!0),H.time("projection-elemMatch");for(z in b.$elemMatch)<span class="missing-if-branch" title="else path not taken" >E</span>if(b.$elemMatch.hasOwnProperty(z))for(D=new h(z),A=0;A&lt;e.length;A++)<span class="missing-if-branch" title="else path not taken" >E</span>if(E=D.value(e[A])[0],E&amp;&amp;E.length)for(B=0;B&lt;E.length;B++)if(J._match(E[B],b.$elemMatch[z],b,"",{})){D.set(e[A],z,[E[B]]);break}H.time("projection-elemMatch")}if(b.$elemsMatch){H.data("flag.elemsMatch",!0),H.time("projection-elemsMatch");for(z in b.$elemsMatch)<span class="missing-if-branch" title="else path not taken" >E</span>if(b.$elemsMatch.hasOwnProperty(z))for(D=new h(z),A=0;A&lt;e.length;A++)<span class="missing-if-branch" title="else path not taken" >E</span>if(E=D.value(e[A])[0],E&amp;&amp;E.length){for(F=[],B=0;B&lt;E.length;B++)J._match(E[B],b.$elemsMatch[z],b,"",{})&amp;&amp;F.push(E[B]);D.set(e[A],z,F)}H.time("projection-elemsMatch")}return H.stop(),e.__fdbOp=H,e.$cursor=Q,e},n.prototype._resolveDynamicQuery=function(a,b){var c,d,e,f,g=this;if("string"==typeof a)return"$$."===a.substr(0,3)?<span class="branch-0 cbranch-no" title="branch not covered" >new h(a.substr(3,a.length-3)).value(b)[0]:</span>new h(a).value(b)[0];c={};for(f in a)<span class="missing-if-branch" title="else path not taken" >E</span>if(a.hasOwnProperty(f))switch(d=typeof a[f],e=a[f],d){case"string":"$$."===e.substr(0,3)?c[f]=new h(e.substr(3,e.length-3)).value(b)[0]:<span class="branch-1 cbranch-no" title="branch not covered" >c[f]=e;</span>break;<span class="branch-1 cbranch-no" title="branch not covered" >case"object":<span class="cstat-no" title="statement not covered" >c[f]=g._resolveDynamicQuery(e,b);<span class="cstat-no" title="statement not covered" >b</span>reak;<span class="branch-2 cbranch-no" title="branch not covered" >d</span></span>efault:<span class="cstat-no" title="statement not covered" >c[f]=e}</span></span>return c},n.prototype.findOne=function(){return this.find.apply(this,arguments)[0]},n.prototype.indexOf=function(a,b){var c,d=this.find(a,{$decouple:!1})[0];return d?!b||<span class="branch-1 cbranch-no" title="branch not covered" >b&amp;</span>&amp;<span class="branch-2 cbranch-no" title="branch not covered" >!b.$orderBy?</span>this._data.indexOf(d):(<span class="branch-1 cbranch-no" title="branch not covered" >b.$decouple=!1,c=this.find(a,b),c.indexOf(d))</span>:<span class="branch-1 cbranch-no" title="branch not covered" >-1}</span>,n.prototype.indexOfDocById=function(a,b){var c,d;return c="object"!=typeof a?this._primaryIndex.get(a):this._primaryIndex.get(a[this._primaryKey]),c?!b||<span class="branch-1 cbranch-no" title="branch not covered" >b&amp;</span>&amp;<span class="branch-2 cbranch-no" title="branch not covered" >!b.$orderBy?</span>this._data.indexOf(c):(<span class="branch-1 cbranch-no" title="branch not covered" >b.$decouple=!1,d=this.find({},b),d.indexOf(c))</span>:<span class="branch-1 cbranch-no" title="branch not covered" >-1}</span>,n.prototype.removeByIndex=<span class="fstat-no" title="function not covered" >function(a){<span class="cstat-no" title="statement not covered" ></span>var b,c;<span class="cstat-no" title="statement not covered" >r</span>eturn b=this._data[a],void 0!==b?(b=this.decouple(b),c=b[this.primaryKey()],this.removeById(c)):!1}</span>,n.prototype.transform=function(a){return void 0!==a?("object"==typeof a?(void 0!==a.enabled&amp;&amp;(this._transformEnabled=a.enabled),void 0!==a.dataIn&amp;&amp;(this._transformIn=a.dataIn),void 0!==a.dataOut&amp;&amp;(this._transformOut=a.dataOut)):this._transformEnabled=a!==!1,this):<span class="branch-1 cbranch-no" title="branch not covered" >{enabled:this._transformEnabled,dataIn:this._transformIn,dataOut:this._transformOut}}</span>,n.prototype.transformIn=function(a){if(this._transformEnabled&amp;&amp;this._transformIn){if(a instanceof Array){var b,c=[];for(b=0;b&lt;a.length;b++)c[b]=this._transformIn(a[b]);return c}return this._transformIn(a)}return a},n.prototype.transformOut=function(a){<span class="missing-if-branch" title="else path not taken" >E</span>if(this._transformEnabled&amp;&amp;this._transformOut){<span class="missing-if-branch" title="else path not taken" >E</span>if(a instanceof Array){var b,c=[];for(b=0;b&lt;a.length;b++)c[b]=this._transformOut(a[b]);return c}<span class="cstat-no" title="statement not covered" >return this._transformOut(a)}<span class="cstat-no" title="statement not covered" ></span>return a}</span>,n.prototype.sort=function(a,b){b=b||<span class="branch-1 cbranch-no" title="branch not covered" >[];</span>var c,d,e=[];for(c in a)a.hasOwnProperty(c)&amp;&amp;(d={},d[c]=a[c],d.___fdbKey=String(c),e.push(d));return e.length&lt;2?this._sort(a,b):this._bucketSort(e,b)},n.prototype._bucketSort=function(a,b){var c,d,e,f,g,h,i=a.shift(),j=[];if(a.length&gt;0){for(b=this._sort(i,b),d=this.bucket(i.___fdbKey,b),e=d.order,g=d.buckets,h=0;h&lt;e.length;h++)f=e[h],c=[].concat(a),j=j.concat(this._bucketSort(c,g[f]));return j}return this._sort(i,b)},n.prototype._sort=function(a,b){var c,d=this,e=new h,f=e.parse(a,!0)[0];if(e.path(f.path),1===f.value)c=function(a,b){var c=e.value(a)[0],f=e.value(b)[0];return d.sortAsc(c,f)};else{<span class="missing-if-branch" title="if path not taken" >I</span>if(-1!==f.value)<span class="cstat-no" title="statement not covered" >throw this.logIdentifier()+" $orderBy clause has invalid direction: "+f.value+", accepted values are 1 or -1 for ascending or descending!";c</span>=function(a,b){var c=e.value(a)[0],f=e.value(b)[0];return d.sortDesc(c,f)}}return b.sort(c)},n.prototype.bucket=function(a,b){var c,d,e,f=[],g={};for(c=0;c&lt;b.length;c++)e=String(b[c][a]),d!==e&amp;&amp;(f.push(e),d=e),g[e]=g[e]||[],g[e].push(b[c]);return{buckets:g,order:f}},n.prototype._analyseQuery=function(a,b,c){var d,e,f,g,i,j,k,l,m,n,o,p={queriesOn:[this._name],indexMatch:[],hasJoin:!1,queriesJoin:!1,joinQueries:{},query:a,options:b},q=[],r=[];if(c.time("checkIndexes"),m=new h,n=m.countKeys(a)){void 0!==a[this._primaryKey]&amp;&amp;(c.time("checkIndexMatch: Primary Key"),p.indexMatch.push({lookup:this._primaryIndex.lookup(a,b),keyData:{matchedKeys:[this._primaryKey],totalKeyCount:n,score:1},index:this._primaryIndex}),c.time("checkIndexMatch: Primary Key"));for(o in this._indexById)if(this._indexById.hasOwnProperty(o)&amp;&amp;(j=this._indexById[o],k=j.name(),c.time("checkIndexMatch: "+k),i=j.match(a,b),i.score&gt;0&amp;&amp;(l=j.lookup(a,b),p.indexMatch.push({lookup:l,keyData:i,index:j})),c.time("checkIndexMatch: "+k),i.score===n))break;c.time("checkIndexes"),p.indexMatch.length&gt;1&amp;&amp;(c.time("findOptimalIndex"),p.indexMatch.sort(function(a,b){return a.keyData.score&gt;b.keyData.score?-1:<span class="branch-1 cbranch-no" title="branch not covered" >a.keyData.score&lt;b.keyData.score?1:a.keyData.score===b.keyData.score?a.lookup.length-b.lookup.length:void 0}</span>),c.time("findOptimalIndex"))}if(b.$join){for(p.hasJoin=!0,d=0;d&lt;b.$join.length;d++)for(e in b.$join[d])b.$join[d].hasOwnProperty(e)&amp;&amp;(q.push(e),"$as"in b.$join[d][e]?r.push(b.$join[d][e].$as):<span class="branch-1 cbranch-no" title="branch not covered" >r.push(e))</span>;for(g=0;g&lt;r.length;g++)f=this._queryReferencesCollection(a,r[g],""),f&amp;&amp;(p.joinQueries[q[g]]=f,p.queriesJoin=!0);p.joinsOn=q,p.queriesOn=p.queriesOn.concat(q)}return p},n.prototype._queryReferencesCollection=function(a,b,c){var d;for(d in a)<span class="missing-if-branch" title="else path not taken" >E</span>if(a.hasOwnProperty(d)){<span class="missing-if-branch" title="else path not taken" >E</span>if(d===b)return c&amp;&amp;(<span class="branch-1 cbranch-no" title="branch not covered" >c+=".")</span>,c+d;<span class="cstat-no" title="statement not covered" >if("object"==typeof a[d])<span class="cstat-no" title="statement not covered" >return c&amp;&amp;(c+="."),c+=d,this._queryReferencesCollection(a[d],b,c)}</span></span>return!1},n.prototype.count=function(a,b){return a?this.find(a,b).length:this._data.length},n.prototype.findSub=function(a,b,c,d){var e,f,g,i=new h(b),j=this.find(a),k=j.length,l=this._db.collection("__FDB_temp_"+this.objectId()),m={parents:k,subDocTotal:0,subDocs:[],pathFound:!1,err:""};for(d=d||{},e=0;k&gt;e;e++)<span class="missing-if-branch" title="else path not taken" >E</span>if(f=i.value(j[e])[0]){<span class="missing-if-branch" title="if path not taken" >I</span>if(l.setData(f),g=l.find(c,d),d.returnFirst&amp;&amp;<span class="branch-1 cbranch-no" title="branch not covered" >g.length)<span class="cstat-no" title="statement not covered" ></span>return g[0];d</span>.$split?<span class="branch-0 cbranch-no" title="branch not covered" >m.subDocs.push(g):</span>m.subDocs=m.subDocs.concat(g),m.subDocTotal+=g.length,m.pathFound=!0}return l.drop(),d.$stats?<span class="branch-0 cbranch-no" title="branch not covered" >m:</span>m.subDocs},n.prototype.insertIndexViolation=function(a){var b,c,d,e=this._indexByName;if(this._primaryIndex.get(a[this._primaryKey]))b=this._primaryIndex;else for(c in e)if(e.hasOwnProperty(c)&amp;&amp;(d=e[c],d.unique()&amp;&amp;d.violation(a))){b=d;break}return b?b.name():!1},n.prototype.ensureIndex=function(a,b){<span class="missing-if-branch" title="if path not taken" >I</span>if(this.isDropped())<span class="cstat-no" title="statement not covered" >throw this.logIdentifier()+" Cannot operate in a dropped state!";t</span>his._indexByName=this._indexByName||{},this._indexById=this._indexById||{};var c