forerunnerdb
Version:
A NoSQL document store database for browsers and Node.js.
4,464 lines (1,163 loc) • 72.8 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">
Collection object used to store data.
</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#line25">line 25</a>
</li></ul></dd>
</dl>
</div>
<h3 class="subsection-title">Members</h3>
<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#line89">line 89</a>
</li></ul></dd>
</dl>
<h3 class="subsection-title">Methods</h3>
<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">
</td>
<td class="attributes">
</td>
<td class="description last"></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">function</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#line1321">line 1321</a>
</li></ul></dd>
</dl>
<h4 class="name" id="bucket"><span class="type-signature"></span>bucket<span class="signature">(key, arr)</span><span class="type-signature"> → {Object}</span></h4>
<div class="description">
Takes an array of objects and returns a new object with the array items
split into buckets by the passed key.
</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 split the array into buckets by.</td>
</tr>
<tr>
<td class="name"><code>arr</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="description last">An array of objects.</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#line2336">line 2336</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="count"><span class="type-signature"></span>count<span class="signature">()</span><span class="type-signature"> → {Number}</span></h4>
<div class="description">
Returns the number of documents currently in 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#line2535">line 2535</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Number</span>
</dd>
</dl>
<h4 class="name" id="data"><span class="type-signature"></span>data<span class="signature">()</span><span class="type-signature"> → {Array}</span></h4>
<div class="description">
Get the internal data
</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#line109">line 109</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array</span>
</dd>
</dl>
<h4 class="name" id="diff"><span class="type-signature"></span>diff<span class="signature">(collection)</span><span class="type-signature"> → {Object}</span></h4>
<div class="description">
Generates a difference object that contains insert, update and remove arrays
representing the operations to execute to make this collection have the same
data as the one passed.
</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 diff against.</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#line2738">line 2738</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="distinct"><span class="type-signature"></span>distinct<span class="signature">(key, query<span class="signature-attributes">opt</span>, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Array}</span></h4>
<div class="description">
Find the distinct values for a specified field across a single collection and
returns the results in an array.
</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>key</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
</td>
<td class="description last">The field path to return distinct values for e.g. "person.name".</td>
</tr>
<tr>
<td class="name"><code>query</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">The query to use to filter the documents used to return values from.</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 query options to use when running the query.</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>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array</span>
</dd>
</dl>
<h4 class="name" id="drop"><span class="type-signature"></span>drop<span class="signature">()</span><span class="type-signature"> → {boolean}</span></h4>
<div class="description">
Drops a collection and all it's stored data from the database.
</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#line117">line 117</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
True on success, false on failure.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">boolean</span>
</dd>
</dl>
<h4 class="name" id="ensureIndex"><span class="type-signature"></span>ensureIndex<span class="signature">(keys, options)</span><span class="type-signature"> → {*}</span></h4>
<div class="description">
Creates an index on the specified 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>keys</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">The object containing keys to index.</td>
</tr>
<tr>
<td class="name"><code>options</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">An options object.</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#line2639">line 2639</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">*</span>
</dd>
</dl>
<h4 class="name" id="explain"><span class="type-signature"></span>explain<span class="signature">(query, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Object}</span></h4>
<div class="description">
Provides a query plan / operations log for a query.
</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>query</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
</td>
<td class="description last">The query to execute.</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 options object.</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#line1696">line 1696</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
The query plan.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Object</span>
</dd>
</dl>
<h4 class="name" id="filter"><span class="type-signature"></span>filter<span class="signature">(query, func, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Array}</span></h4>
<div class="description">
Executes a method against each document that matches query and returns an
array of documents that may have been modified by the method.
</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>query</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
</td>
<td class="description last">The query object.</td>
</tr>
<tr>
<td class="name"><code>func</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="attributes">
</td>
<td class="description last">The method that each document is passed to. If this method
returns false for a particular document it is excluded from the results.</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 options object.</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#line488">line 488</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array</span>
</dd>
</dl>
<h4 class="name" id="filterUpdate"><span class="type-signature"></span>filterUpdate<span class="signature">(query, func, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Array}</span></h4>
<div class="description">
Executes a method against each document that matches query and then executes
an update based on the return data of the method.
</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>query</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
</td>
<td class="description last">The query object.</td>
</tr>
<tr>
<td class="name"><code>func</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="attributes">
</td>
<td class="description last">The method that each document is passed to. If this method
returns false for a particular document it is excluded from the update.</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 options object passed to the initial find call.</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#line501">line 501</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array</span>
</dd>
</dl>
<h4 class="name" id="find"><span class="type-signature"></span>find<span class="signature">(query, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Array}</span></h4>
<div class="description">
Queries the collection based on the query object passed.
</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>query</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
</td>
<td class="description last">The query key/values that a document must match in
order for it to be returned in the result array.</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">An optional options object.</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#line1725">line 1725</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
The results array from the find operation, containing all
documents that matched the query.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array</span>
</dd>
</dl>
<h4 class="name" id="findById"><span class="type-signature"></span>findById<span class="signature">(id, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Array}</span></h4>
<div class="description">
Helper method to find a document by it's id.
</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>id</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
</td>
<td class="description last">The id of the document.</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, allowed keys are sort and limit.</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#line1648">line 1648</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
The items that were updated.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array</span>
</dd>
</dl>
<h4 class="name" id="findOne"><span class="type-signature"></span>findOne<span class="signature">()</span><span class="type-signature"> → {*}</span></h4>
<div class="description">
Returns one document that satisfies the specified query criteria. If multiple
documents satisfy the query, this method returns the first document to match
the query.
</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#line2127">line 2127</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">*</span>
</dd>
</dl>
<h4 class="name" id="findSub"><span class="type-signature"></span>findSub<span class="signature">(match, path, subDocQuery, subDocOptions)</span><span class="type-signature"> → {*}</span></h4>
<div class="description">
Finds sub-documents from the collection's documents.
</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>match</code></td>
<td class="type">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>path</code></td>
<td class="type">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>subDocQuery</code></td>
<td class="type">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>subDocOptions</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#line2552">line 2552</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">*</span>
</dd>
</dl>
<h4 class="name" id="index"><span class="type-signature"></span>index<span class="signature">(name)</span><span class="type-signature"> → {*}</span></h4>
<div class="description">
Gets an index by it's 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>name</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">The name of the index to retreive.</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#line2717">line 2717</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">*</span>
</dd>
</dl>
<h4 class="name" id="indexOf"><span class="type-signature"></span>indexOf<span class="signature">(query)</span><span class="type-signature"> → {Number}</span></h4>
<div class="description">
Gets the index in the collection data array of the first item matched by
the passed query object.
</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">
<span class="param-type">Object</span>
</td>
<td class="description last">The query to run to find the item to return the index of.</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#line2137">line 2137</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Number</span>
</dd>
</dl>
<h4 class="name" id="indexOfDocById"><span class="type-signature"></span>indexOfDocById<span class="signature">(item)</span><span class="type-signature"> → {Number}</span></h4>
<div class="description">
Returns the index of the document identified by the passed item's primary key.
</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>item</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">The item whose primary key should be used to lookup.</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#line1565">line 1565</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
The index the item with the matching primary key is occupying.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Number</span>
</dd>
</dl>
<h4 class="name" id="insert"><span class="type-signature"></span>insert<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">
</td>
<td class="attributes">
</td>
<td class="description last"></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">function</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#line1298">line 1298</a>
</li></ul></dd>
</dl>
<h4 class="name" id="insertIndexViolation"><span class="type-signature"></span>insertIndexViolation<span class="signature">(doc)</span><span class="type-signature"> → {Boolean}</span></h4>
<div class="description">
Checks that the passed document will not violate any index rules if
inserted into the collection.
</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 check indexes against.</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#line2605">line 2605</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Either false (no violation occurred) or true if
a violation was detected.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Boolean</span>
</dd>
</dl>
<h4 class="name" id="lastOp"><span class="type-signature"></span>lastOp<span class="signature">()</span><span class="type-signature"> → {Object}</span></h4>
<div class="description">
Gets the last reporting operation's details such as run time.
</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#line2727">line 2727</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="options"><span class="type-signature"></span>options<span class="signature">(obj<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {<a href="global.html#object">object</a>}</span></h4>
<div class="description">
Generates an options object with default values or adds default
values to a passed object if those values are not currently set
to anything.
</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>obj</code></td>
<td class="type">
<span class="param-type"><a href="global.html#object">object</a></span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">Optional options object to modify.</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#line1708">line 1708</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
The options object.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="global.html#object">object</a></span>
</dd>
</dl>
<h4 class="name" id="peek"><span class="type-signature"></span>peek<span class="signature">(search, options)</span><span class="type-signature"> → {Array}</span></h4>
<div class="description">
Finds all documents that contain the passed string or search object
regardless of where the string might occur within the document. This
will match strings from the start, middle or end of the document's
string (partial match).
</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>search</code></td>
<td class="type">
</td>
<td class="description last">The string to search for. Case sensitive.</td>
</tr>
<tr>
<td class="name"><code>options</code></td>
<td class="type">
</td>
<td class="description last">A standard find() options object.</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#line1663">line 1663</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
An array of documents that matched the search string.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array</span>
</dd>
</dl>
<h4 class="name" id="primaryKey"><span class="type-signature"></span>primaryKey<span class="signature">(keyName<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {*}</span></h4>
<div class="description">
Gets / sets the primary key for this 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>keyName</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">The name of the primary key.</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#line168">line 168</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">*</span>
</dd>
</dl>
<h4 class="name" id="processQueue"><span class="type-signature"></span>processQueue<span class="signature">(type, callback)</span><span class="type-signature"></span></h4>
<div class="description">
Processes a deferred action queue.
</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>type</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">The queue name to process.</td>
</tr>
<tr>
<td class="name"><code>callback</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="description last">A method to call when the queue has processed.</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#line1260">line 1260</a>
</li></ul></dd>
</dl>
<h4 class="name" id="remove"><span class="type-signature"></span>remove<span class="signature">(query, options<span class="signature-attributes">opt</span>, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Array}</span></h4>
<div class="description">
Removes any documents from the collection that match the search query
key/values.
</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>query</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
</td>
<td class="description last">The query object.</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">An options object.</td>
</tr>
<tr>
<td class="name"><code>callback</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<