forerunnerdb
Version:
A NoSQL document store database for browsers and Node.js.
4,484 lines (1,109 loc) • 158 kB
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Class: Collection</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Class: Collection</h1>
<section>
<header>
<h2>
Collection
</h2>
</header>
<article>
<div class="container-overview">
<h4 class="name" id="Collection"><span class="type-signature"></span>new Collection<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
Creates a new collection. Collections store multiple documents and
handle CRUD against those documents.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Collection.js.html">Collection.js</a>, <a href="Collection.js.html#line21">line 21</a>
</li></ul></dd>
</dl>
</div>
<h3 class="subsection-title">Members</h3>
<h4 class="name" id="_addView"><span class="type-signature">(private) </span>_addView<span class="type-signature"></span></h4>
<div class="description">
Adds a view to the internal view lookup.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="View.js.html">View.js</a>, <a href="View.js.html#line1038">line 1038</a>
</li></ul></dd>
</dl>
<h4 class="name" id="_removeView"><span class="type-signature">(private) </span>_removeView<span class="type-signature"></span></h4>
<div class="description">
Removes a view from the internal view lookup.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="View.js.html">View.js</a>, <a href="View.js.html#line1052">line 1052</a>
</li></ul></dd>
</dl>
<h4 class="name" id="areaChart"><span class="type-signature"></span>areaChart<span class="type-signature"> :<a href="Overload.html">Overload</a></span></h4>
<div class="description">
Creates an area chart from the collection.
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type"><a href="Overload.html">Overload</a></span>
</li>
</ul>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Highchart.js.html">Highchart.js</a>, <a href="Highchart.js.html#line413">line 413</a>
</li></ul></dd>
</dl>
<h4 class="name" id="barChart"><span class="type-signature"></span>barChart<span class="type-signature"> :<a href="Overload.html">Overload</a></span></h4>
<div class="description">
Creates a bar chart from the collection.
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type"><a href="Overload.html">Overload</a></span>
</li>
</ul>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Highchart.js.html">Highchart.js</a>, <a href="Highchart.js.html#line513">line 513</a>
</li></ul></dd>
</dl>
<h4 class="name" id="columnChart"><span class="type-signature"></span>columnChart<span class="type-signature"> :<a href="Overload.html">Overload</a></span></h4>
<div class="description">
Creates a column chart from the collection.
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type"><a href="Overload.html">Overload</a></span>
</li>
</ul>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Highchart.js.html">Highchart.js</a>, <a href="Highchart.js.html#line463">line 463</a>
</li></ul></dd>
</dl>
<h4 class="name" id="crc"><span class="type-signature"></span>crc<span class="type-signature"></span></h4>
<div class="description">
Returns a checksum of a string.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Collection.js.html">Collection.js</a>, <a href="Collection.js.html#line92">line 92</a>
</li></ul></dd>
</dl>
<h4 class="name" id="lineChart"><span class="type-signature"></span>lineChart<span class="type-signature"> :<a href="Overload.html">Overload</a></span></h4>
<div class="description">
Creates a line chart from the collection.
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type"><a href="Overload.html">Overload</a></span>
</li>
</ul>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Highchart.js.html">Highchart.js</a>, <a href="Highchart.js.html#line363">line 363</a>
</li></ul></dd>
</dl>
<h4 class="name" id="pieChart"><span class="type-signature"></span>pieChart<span class="type-signature"> :<a href="Overload.html">Overload</a></span></h4>
<div class="description">
Creates a pie chart from the collection.
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type"><a href="Overload.html">Overload</a></span>
</li>
</ul>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Highchart.js.html">Highchart.js</a>, <a href="Highchart.js.html#line313">line 313</a>
</li></ul></dd>
</dl>
<h4 class="name" id="stackedBarChart"><span class="type-signature"></span>stackedBarChart<span class="type-signature"> :<a href="Overload.html">Overload</a></span></h4>
<div class="description">
Creates a stacked bar chart from the collection.
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type"><a href="Overload.html">Overload</a></span>
</li>
</ul>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Highchart.js.html">Highchart.js</a>, <a href="Highchart.js.html#line563">line 563</a>
</li></ul></dd>
</dl>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="._addGrid"><span class="type-signature">(private, static) </span>_addGrid<span class="signature">(grid)</span><span class="type-signature"> → {<a href="Collection.html">Collection</a>}</span></h4>
<div class="description">
Adds a grid to the internal grid lookup.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>grid</code></td>
<td class="type">
<span class="param-type"><a href="Grid.html">Grid</a></span>
</td>
<td class="description last">The grid to add.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Grid.js.html">Grid.js</a>, <a href="Grid.js.html#line570">line 570</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="Collection.html">Collection</a></span>
</dd>
</dl>
<h4 class="name" id="._removeGrid"><span class="type-signature">(private, static) </span>_removeGrid<span class="signature">(grid)</span><span class="type-signature"> → {<a href="Collection.html">Collection</a>}</span></h4>
<div class="description">
Removes a grid from the internal grid lookup.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>grid</code></td>
<td class="type">
<span class="param-type"><a href="Grid.html">Grid</a></span>
</td>
<td class="description last">The grid to remove.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Grid.js.html">Grid.js</a>, <a href="Grid.js.html#line587">line 587</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="Collection.html">Collection</a></span>
</dd>
</dl>
<h4 class="name" id=".collateAdd"><span class="type-signature">(static) </span>collateAdd<span class="signature">(collection, keyName<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
<div class="description">
Adds a data source to collate data from and specifies the
key name to collate data to.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>collection</code></td>
<td class="type">
<span class="param-type"><a href="Collection.html">Collection</a></span>
</td>
<td class="attributes">
</td>
<td class="description last">The collection to collate data from.</td>
</tr>
<tr>
<td class="name"><code>keyName</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">Optional name of the key to collate data to.
If none is provided the record CRUD is operated on the root collection
data.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Collection.js.html">Collection.js</a>, <a href="Collection.js.html#line3150">line 3150</a>
</li></ul></dd>
</dl>
<h4 class="name" id=".collateAdd"><span class="type-signature">(static) </span>collateAdd<span class="signature">(collection, process)</span><span class="type-signature"></span></h4>
<div class="description">
Adds a data source to collate data from and specifies a process
method that will handle the collation functionality (for custom
collation).
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>collection</code></td>
<td class="type">
<span class="param-type"><a href="Collection.html">Collection</a></span>
</td>
<td class="description last">The collection to collate data from.</td>
</tr>
<tr>
<td class="name"><code>process</code></td>
<td class="type">
<span class="param-type"><a href="global.html#function">function</a></span>
</td>
<td class="description last">The process method.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Collection.js.html">Collection.js</a>, <a href="Collection.js.html#line3215">line 3215</a>
</li></ul></dd>
</dl>
<h4 class="name" id=".grid"><span class="type-signature">(static) </span>grid<span class="signature">(selector, template, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {*}</span></h4>
<div class="description">
Creates a grid and assigns the collection as its data source.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>selector</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
</td>
<td class="description last">jQuery selector of grid output target.</td>
</tr>
<tr>
<td class="name"><code>template</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
</td>
<td class="description last">The table template to use when rendering the grid.</td>
</tr>
<tr>
<td class="name"><code>options</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">The options object to apply to the grid.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Grid.js.html">Grid.js</a>, <a href="Grid.js.html#line489">line 489</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">*</span>
</dd>
</dl>
<h4 class="name" id=".isLinked"><span class="type-signature">(static) </span>isLinked<span class="signature">()</span><span class="type-signature"> → {Boolean}</span></h4>
<div class="description">
Checks if the instance is data-bound to any DOM elements.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="AutoBind.js.html">AutoBind.js</a>, <a href="AutoBind.js.html#line45">line 45</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
True if linked, false if not.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Boolean</span>
</dd>
</dl>
<h4 class="name" id=".link"><span class="type-signature">(static) </span>link<span class="signature">(scope, varName, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
<div class="description">
Creates a link to the DOM between the collection data and the elements
in the passed output selector. When new elements are needed or changes
occur the passed templateSelector is used to get the template that is
output to the DOM.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>scope</code></td>
<td class="type">
</td>
<td class="attributes">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>varName</code></td>
<td class="type">
</td>
<td class="attributes">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>options</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">Optional extra options.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Angular.js.html">Angular.js</a>, <a href="Angular.js.html#line24">line 24</a>
</li></ul></dd>
<dt class="tag-see">See:</dt>
<dd class="tag-see">
<ul>
<li>unlink</li>
</ul>
</dd>
</dl>
<h4 class="name" id=".link"><span class="type-signature">(static) </span>link<span class="signature">(outputTargetSelector, templateSelector, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
<div class="description">
Creates a link to the DOM between the collection data and the elements
in the passed output selector. When new elements are needed or changes
occur the passed templateSelector is used to get the template that is
output to the DOM.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>outputTargetSelector</code></td>
<td class="type">
</td>
<td class="attributes">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>templateSelector</code></td>
<td class="type">
</td>
<td class="attributes">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>options</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">Optional extra options.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="AutoBind.js.html">AutoBind.js</a>, <a href="AutoBind.js.html#line55">line 55</a>
</li></ul></dd>
<dt class="tag-see">See:</dt>
<dd class="tag-see">
<ul>
<li>unlink</li>
</ul>
</dd>
</dl>
<h4 class="name" id=".unGrid"><span class="type-signature">(static) </span>unGrid<span class="signature">(selector, template, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {*}</span></h4>
<div class="description">
Removes a grid safely from the DOM. Must be called when grid is
no longer required / is being removed from DOM otherwise references
will stick around and cause memory leaks.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>selector</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
</td>
<td class="description last">jQuery selector of grid output target.</td>
</tr>
<tr>
<td class="name"><code>template</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
</td>
<td class="description last">The table template to use when rendering the grid.</td>
</tr>
<tr>
<td class="name"><code>options</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">The options object to apply to the grid.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Grid.js.html">Grid.js</a>, <a href="Grid.js.html#line525">line 525</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">*</span>
</dd>
</dl>
<h4 class="name" id=".unlink"><span class="type-signature">(static) </span>unlink<span class="signature">(outputTargetSelector, templateSelector)</span><span class="type-signature"></span></h4>
<div class="description">
Removes a link to the DOM between the collection data and the elements
in the passed output selector that was created using the link() method.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>outputTargetSelector</code></td>
<td class="type">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>templateSelector</code></td>
<td class="type">
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="AutoBind.js.html">AutoBind.js</a>, <a href="AutoBind.js.html#line185">line 185</a>
</li></ul></dd>
</dl>
<h4 class="name" id="_addOldView"><span class="type-signature">(private) </span>_addOldView<span class="signature">(view)</span><span class="type-signature"> → {<a href="Collection.html">Collection</a>}</span></h4>
<div class="description">
Adds a view to the internal view lookup.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>view</code></td>
<td class="type">
<span class="param-type"><a href="View.html">View</a></span>
</td>
<td class="description last">The view to add.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="OldView.js.html">OldView.js</a>, <a href="OldView.js.html#line593">line 593</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="Collection.html">Collection</a></span>
</dd>
</dl>
<h4 class="name" id="_analyseQuery"><span class="type-signature">(private) </span>_analyseQuery<span class="signature">(query, options, op)</span><span class="type-signature"> → {Object}</span></h4>
<div class="description">
Internal method that takes a search query and options and returns an object
containing details about the query which can be used to optimise the search.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>query</code></td>
<td class="type">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>options</code></td>
<td class="type">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>op</code></td>
<td class="type">
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Collection.js.html">Collection.js</a>, <a href="Collection.js.html#line2693">line 2693</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Object</span>
</dd>
</dl>
<h4 class="name" id="_bucketSort"><span class="type-signature">(private) </span>_bucketSort<span class="signature">(keyArr, arr)</span><span class="type-signature"> → {*}</span></h4>
<div class="description">
Takes array of sort paths and sorts them into buckets before returning final
array fully sorted by multi-keys.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>keyArr</code></td>
<td class="type">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>arr</code></td>
<td class="type">
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Collection.js.html">Collection.js</a>, <a href="Collection.js.html#line2580">line 2580</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">*</span>
</dd>
</dl>
<h4 class="name" id="_dataInsertAtIndex"><span class="type-signature">(private) </span>_dataInsertAtIndex<span class="signature">(index, doc)</span><span class="type-signature"></span></h4>
<div class="description">
Inserts a document into the internal collection data array at
Inserts a document into the internal collection data array at
the specified index.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>index</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last">The index to insert at.</td>
</tr>
<tr>
<td class="name"><code>doc</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last">The document to insert.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Collection.js.html">Collection.js</a>, <a href="Collection.js.html#line1581">line 1581</a>
</li></ul></dd>
</dl>
<h4 class="name" id="_dataRemoveAtIndex"><span class="type-signature">(private) </span>_dataRemoveAtIndex<span class="signature">(index)</span><span class="type-signature"></span></h4>
<div class="description">
Removes a document from the internal collection data array at
the specified index.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>index</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last">The index to remove from.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Collection.js.html">Collection.js</a>, <a href="Collection.js.html#line1591">line 1591</a>
</li></ul></dd>
</dl>
<h4 class="name" id="_dataReplace"><span class="type-signature">(private) </span>_dataReplace<span class="signature">(data)</span><span class="type-signature"></span></h4>
<div class="description">
Replaces all data in the collection's internal data array with
the passed array of data.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>data</code></td>
<td class="type">
<span class="param-type">array</span>
</td>
<td class="description last">The array of data to replace existing data with.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Collection.js.html">Collection.js</a>, <a href="Collection.js.html#line1601">line 1601</a>
</li></ul></dd>
</dl>
<h4 class="name" id="_insert"><span class="type-signature">(private) </span>_insert<span class="signature">(doc, index<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Boolean|Object}</span></h4>
<div class="description">
Internal method to insert a document into the collection. Will
check for index violations before allowing the document to be inserted.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>doc</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
</td>
<td class="description last">The document to insert after passing index violation
tests.</td>
</tr>
<tr>
<td class="name"><code>index</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">Optional index to insert the document at.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Collection.js.html">Collection.js</a>, <a href="Collection.js.html#line1513">line 1513</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
True on success, false if no document passed,
or an object containing details about an index violation if one occurred.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Boolean</span>
|
<span class="param-type">Object</span>
</dd>
</dl>
<h4 class="name" id="_insertHandle"><span class="type-signature"></span>_insertHandle<span class="signature">(data, index<span class="signature-attributes">opt</span>, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
<div class="description">
Inserts a document or array of documents into the collection.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>data</code></td>
<td class="type">
<span class="param-type">Object</span>
|
<span class="param-type">Array</span>
</td>
<td class="attributes">
</td>
<td class="description last">Either a document object or array of document</td>
</tr>
<tr>
<td class="name"><code>index</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">Optional index to insert the record at.</td>
</tr>
<tr>
<td class="name"><code>callback</code></td>
<td class="type">
<span class="param-type"><a href="global.html#function">function</a></span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">Optional callback called once action is complete.
objects to insert into the collection.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Collection.js.html">Collection.js</a>, <a href="Collection.js.html#line1432">line 1432</a>
</li></ul></dd>
</dl>
<h4 class="name" id="_insertIntoIndexes"><span class="type-signature">(private) </span>_insertIntoIndexes<span class="signature">(doc)</span><span class="type-signature"></span></h4>
<div class="description">
Inserts a document into the collection indexes.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>doc</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">The document to insert.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Collection.js.html">Collection.js</a>, <a href="Collection.js.html#line1617">line 1617</a>
</li></ul></dd>
</dl>
<h4 class="name" id="_isPositionalKey"><span class="type-signature">(private) </span>_isPositionalKey<span class="signature">(key)</span><span class="type-signature"> → {Boolean}</span></h4>
<div class="description">
Determines if the passed key has an array positional mark (a dollar at the end
of its name).
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>key</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">The key to check.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Collection.js.html">Collection.js</a>, <a href="Collection.js.html#line1209">line 1209</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
True if it is a positional or false if not.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Boolean</span>
</dd>
</dl>
<h4 class="name" id="_onChange"><span class="type-signature">(private) </span>_onChange<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
Handles any change to the collection.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Collection.js.html">Collection.js</a>, <a href="Collection.js.html#line228">line 228</a>
</li></ul></dd>
</dl>
<h4 class="name" id="_onInsert"><span class="type-signature">(private) </span>_onInsert<span class="signature">(inserted, failed)</span><span class="type-signature"></span></h4>
<div class="description">
Handles insert events and routes changes to binds and views as required.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>inserted</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="description last">An array of inserted documents.</td>
</tr>
<tr>
<td class="name"><code>failed</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="description last">An array of documents that failed to insert.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Collection.js.html">Collection.js</a>, <a href="Collection.js.html#line202">line 202</a>
</li></ul></dd>
</dl>
<h4 class="name" id="_onRemove"><span class="type-signature">(private) </span>_onRemove<span class="signature">(items)</span><span class="type-signature"></span></h4>
<div class="description">
Handles remove events and routes changes to binds and views as required.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>items</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="description last">An array of removed documents.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Collection.js.html">Collection.js</a>, <a href="Collection.js.html#line220">line 220</a>
</li></ul></dd>
</dl>
<h4 class="name" id="_onUpdate"><span class="type-signature">