morefun-forerunnerdb
Version:
A NoSQL document store database for browsers and Node.js.
4,731 lines (1,165 loc) • 75.6 kB
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Class: Db</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: Db</h1>
<section>
<header>
<h2>Db</h2>
</header>
<article>
<div class="container-overview">
<h4 class="name" id="Db"><span class="type-signature"></span>new Db<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
Creates a new ForerunnerDB database instance.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Db.js.html">Db.js</a>, <a href="Db.js.html#line17">line 17</a>
</li></ul></dd>
</dl>
</div>
<h3 class="subsection-title">Members</h3>
<h4 class="name" id="Checksum"><span class="type-signature"></span>Checksum<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="Db.js.html">Db.js</a>, <a href="Db.js.html#line208">line 208</a>
</li></ul></dd>
</dl>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id=".collection"><span class="type-signature">(static) </span>collection<span class="signature">(collectionName)</span><span class="type-signature"> → {<a href="Collection.html">Collection</a>}</span></h4>
<div class="description">
Get a collection by name. If the collection does not already exist
then one is created for that name automatically.
</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>collectionName</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">The name of 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#line3629">line 3629</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=".collection"><span class="type-signature">(static) </span>collection<span class="signature">()</span><span class="type-signature"> → {<a href="Collection.html">Collection</a>}</span></h4>
<div class="description">
Get a collection with no name (generates a random name). If the
collection does not already exist then one is created for that
name automatically.
</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#line3592">line 3592</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=".collection"><span class="type-signature">(static) </span>collection<span class="signature">(collectionName, primaryKey)</span><span class="type-signature"> → {<a href="Collection.html">Collection</a>}</span></h4>
<div class="description">
Get a collection by name. If the collection does not already exist
then one is created for that name automatically.
</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>collectionName</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">The name of the collection.</td>
</tr>
<tr>
<td class="name"><code>primaryKey</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">Optional primary key to specify the
primary key field on the collection objects. Defaults to "_id".</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#line3643">line 3643</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=".collection"><span class="type-signature">(static) </span>collection<span class="signature">(collectionName, options)</span><span class="type-signature"> → {<a href="Collection.html">Collection</a>}</span></h4>
<div class="description">
Get a collection by name. If the collection does not already exist
then one is created for that name automatically.
</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>collectionName</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">The name of the collection.</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#line3660">line 3660</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=".collection"><span class="type-signature">(static) </span>collection<span class="signature">(options)</span><span class="type-signature"> → {*}</span></h4>
<div class="description">
The main handler method. This gets called by all the other
variants and handles the actual logic of the overloaded 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>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#line3693">line 3693</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">*</span>
</dd>
</dl>
<h4 class="name" id=".collection"><span class="type-signature">(static) </span>collection<span class="signature">(collectionName, primaryKey, options)</span><span class="type-signature"> → {<a href="Collection.html">Collection</a>}</span></h4>
<div class="description">
Get a collection by name. If the collection does not already exist
then one is created for that name automatically.
</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>collectionName</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">The name of the collection.</td>
</tr>
<tr>
<td class="name"><code>primaryKey</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">Optional primary key to specify the
primary key field on the collection objects. Defaults to "_id".</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#line3675">line 3675</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=".collection"><span class="type-signature">(static) </span>collection<span class="signature">(data)</span><span class="type-signature"> → {<a href="Collection.html">Collection</a>}</span></h4>
<div class="description">
Get a collection by name. If the collection does not already exist
then one is created for that name automatically.
</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">Object</span>
</td>
<td class="description last">An options object or a collection instance.</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#line3606">line 3606</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=".collectionGroup"><span class="type-signature">(static) </span>collectionGroup<span class="signature">(name)</span><span class="type-signature"> → {*}</span></h4>
<div class="description">
Creates a new collectionGroup instance or returns an existing
instance if one already exists with the passed 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 instance.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="CollectionGroup.js.html">CollectionGroup.js</a>, <a href="CollectionGroup.js.html#line307">line 307</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">*</span>
</dd>
</dl>
<h4 class="name" id=".document"><span class="type-signature">(static) </span>document<span class="signature">(name)</span><span class="type-signature"> → {*}</span></h4>
<div class="description">
Creates a new document instance or returns an existing
instance if one already exists with the passed 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 instance.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Document.js.html">Document.js</a>, <a href="Document.js.html#line399">line 399</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">*</span>
</dd>
</dl>
<h4 class="name" id=".documents"><span class="type-signature">(static) </span>documents<span class="signature">()</span><span class="type-signature"> → {Array}</span></h4>
<div class="description">
Returns an array of documents the DB currently has.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Document.js.html">Document.js</a>, <a href="Document.js.html#line436">line 436</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
An array of objects containing details of each document
the database is currently managing.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array</span>
</dd>
</dl>
<h4 class="name" id=".drop"><span class="type-signature">(static) </span>drop<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
Drops the database.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Db.js.html">Db.js</a>, <a href="Db.js.html#line384">line 384</a>
</li></ul></dd>
</dl>
<h4 class="name" id=".drop"><span class="type-signature">(static) </span>drop<span class="signature">(removePersist)</span><span class="type-signature"></span></h4>
<div class="description">
Drops the database with optional persistent storage drop. Persistent
storage is dropped by default if no preference is provided.
</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>removePersist</code></td>
<td class="type">
<span class="param-type">Boolean</span>
</td>
<td class="description last">Drop persistent storage for this database.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Db.js.html">Db.js</a>, <a href="Db.js.html#line448">line 448</a>
</li></ul></dd>
</dl>
<h4 class="name" id=".drop"><span class="type-signature">(static) </span>drop<span class="signature">(removePersist, callback)</span><span class="type-signature"></span></h4>
<div class="description">
Drops the database and optionally controls dropping persistent storage
and callback 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>removePersist</code></td>
<td class="type">
<span class="param-type">Boolean</span>
</td>
<td class="description last">Drop persistent storage for this database.</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="description last">Optional callback method.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Db.js.html">Db.js</a>, <a href="Db.js.html#line477">line 477</a>
</li></ul></dd>
</dl>
<h4 class="name" id=".drop"><span class="type-signature">(static) </span>drop<span class="signature">(callback)</span><span class="type-signature"></span></h4>
<div class="description">
Drops the database with optional callback 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>callback</code></td>
<td class="type">
<span class="param-type"><a href="global.html#function">function</a></span>
</td>
<td class="description last">Optional callback method.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Db.js.html">Db.js</a>, <a href="Db.js.html#line411">line 411</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 based on the passed arguments.
</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">The jQuery selector of the grid to retrieve.</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#line664">line 664</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">*</span>
</dd>
</dl>
<h4 class="name" id=".gridExists"><span class="type-signature">(static) </span>gridExists<span class="signature">(selector)</span><span class="type-signature"> → {<a href="global.html#boolean">boolean</a>}</span></h4>
<div class="description">
Determine if a grid with the passed name already exists.
</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>selector</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">The jQuery selector to bind the grid to.</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#line653">line 653</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="global.html#boolean">boolean</a></span>
</dd>
</dl>
<h4 class="name" id=".grids"><span class="type-signature">(static) </span>grids<span class="signature">()</span><span class="type-signature"> → {Array}</span></h4>
<div class="description">
Returns an array of grids the DB currently has.
</div>
<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#line704">line 704</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
An array of objects containing details of each grid
the database is currently managing.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array</span>
</dd>
</dl>
<h4 class="name" id=".moduleLoaded"><span class="type-signature">(static) </span>moduleLoaded<span class="signature">(moduleName, success, failure)</span><span class="type-signature"></span></h4>
<div class="description">
Checks if a module is loaded and if so calls the passed
success method, otherwise calls the failure 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>moduleName</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">The name of the module to check for.</td>
</tr>
<tr>
<td class="name"><code>success</code></td>
<td class="type">
<span class="param-type"><a href="global.html#function">function</a></span>
</td>
<td class="description last">The callback method to call if module is loaded.</td>
</tr>
<tr>
<td class="name"><code>failure</code></td>
<td class="type">
<span class="param-type"><a href="global.html#function">function</a></span>
</td>
<td class="description last">The callback method to call if module not loaded.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Db.js.html">Db.js</a>, <a href="Db.js.html#line83">line 83</a>
</li></ul></dd>
</dl>
<h4 class="name" id=".moduleLoaded"><span class="type-signature">(static) </span>moduleLoaded<span class="signature">(moduleName)</span><span class="type-signature"> → {Boolean}</span></h4>
<div class="description">
Checks if a module has been loaded into the database.
</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>moduleName</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">The name of the module to check for.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Db.js.html">Db.js</a>, <a href="Db.js.html#line32">line 32</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
True if the module is loaded, false if not.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Boolean</span>
</dd>
</dl>
<h4 class="name" id=".moduleLoaded"><span class="type-signature">(static) </span>moduleLoaded<span class="signature">(moduleName, callback)</span><span class="type-signature"></span></h4>
<div class="description">
Checks if a module is loaded and if so calls the passed
callback 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>moduleName</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">The name of the module to check for.</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="description last">The callback method to call if module is loaded.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Db.js.html">Db.js</a>, <a href="Db.js.html#line58">line 58</a>
</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 based on the passed arguments.
</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">The jQuery selector of the grid to retrieve.</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#line684">line 684</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">*</span>
</dd>
</dl>
<h4 class="name" id="arrayToCollection"><span class="type-signature"></span>arrayToCollection<span class="signature">(arr)</span><span class="type-signature"> → {<a href="Collection.html">Collection</a>}</span></h4>
<div class="description">
Converts a normal javascript array of objects into a DB 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>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="Db.js.html">Db.js</a>, <a href="Db.js.html#line234">line 234</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
A new collection instance with the data set to the
array passed.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="Collection.html">Collection</a></span>
</dd>
</dl>
<h4 class="name" id="collectionExists"><span class="type-signature"></span>collectionExists<span class="signature">(viewName)</span><span class="type-signature"> → {<a href="global.html#boolean">boolean</a>}</span></h4>
<div class="description">
Determine if a collection with the passed name already exists.
</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>viewName</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">The name of the collection to check for.</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#line3762">line 3762</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="global.html#boolean">boolean</a></span>
</dd>
</dl>
<h4 class="name" id="collectionGroups"><span class="type-signature"></span>collectionGroups<span class="signature">()</span><span class="type-signature"> → {Array}</span></h4>
<div class="description">
Returns an array of collection groups the DB currently has.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="CollectionGroup.js.html">CollectionGroup.js</a>, <a href="CollectionGroup.js.html#line344">line 344</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
An array of objects containing details of each collection group
the database is currently managing.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array</span>
</dd>
</dl>
<h4 class="name" id="collections"><span class="type-signature"></span>collections<span class="signature">(search)</span><span class="type-signature"> → {Array}</span></h4>
<div class="description">
Returns an array of collections the DB currently has.
</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">
<span class="param-type">String</span>
|
<span class="param-type">RegExp</span>
</td>
<td class="description last">The optional search string or
regular expression to use to match collection names 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#line3774">line 3774</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
An array of objects containing details of each
collection the database is currently managing.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array</span>
</dd>
</dl>
<h4 class="name" id="emit"><span class="type-signature"></span>emit<span class="signature">(event, data<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {*}</span></h4>
<div class="description">
Emits an event by name with the given data.
</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>event</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
</td>
<td class="description last">The name of the event to emit.</td>
</tr>
<tr>
<td class="name"><code>data</code></td>
<td class="type">
<span class="param-type">*</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">The data to emit with the event.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Db.js.html">Db.js</a>, <a href="Db.js.html#line279">line 279</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">*</span>
</dd>
</dl>
<h4 class="name" id="isClient"><span class="type-signature"></span>isClient<span class="signature">()</span><span class="type-signature"> → {<a href="global.html#boolean">boolean</a>}</span></h4>
<div class="description">
Returns true if ForerunnerDB is running on a client browser.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Db.js.html">Db.js</a>, <a href="Db.js.html#line191">line 191</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="global.html#boolean">boolean</a></span>
</dd>
</dl>
<h4 class="name" id="isClient"><span class="type-signature"></span>isClient<span class="signature">()</span><span class="type-signature"> → {Boolean}</span></h4>
<div class="description">
Checks if the database is running on a client (browser) or
a server (node.js).
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Db.js.html">Db.js</a>, <a href="Db.js.html#line215">line 215</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Returns true if running on a browser.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Boolean</span>
</dd>
</dl>
<h4 class="name" id="isServer"><span class="type-signature"></span>isServer<span class="signature">()</span><span class="type-signature"> → {<a href="global.html#boolean">boolean</a>}</span></h4>
<div class="description">
Returns true if ForerunnerDB is running on a server.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Db.js.html">Db.js</a>, <a href="Db.js.html#line199">line 199</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="global.html#boolean">boolean</a></span>
</dd>
</dl>
<h4 class="name" id="isServer"><span class="type-signature"></span>isServer<span class="signature">()</span><span class="type-signature"> → {Boolean}</span></h4>
<div class="description">
Checks if the database is running on a client (browser) or
a server (node.js).
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Db.js.html">Db.js</a>, <a href="Db.js.html#line224">line 224</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Returns true if running on a server.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Boolean</span>
</dd>
</dl>
<h4 class="name" id="load"><span class="type-signature"></span>load<span class="signature">(callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
<div class="description">
Loads an entire database's data from persistent storage.
</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>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">The method to call when the load function
has completed.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="NodePersist.js.html">NodePersist.js</a>, <a href="NodePersist.js.html#line649">line 649</a>
</li></ul></dd>
</dl>
<h4 class="name" id="off"><span class="type-signature"></span>off<span class="signature">(event, listener)</span><span class="type-signature"> → {*}</span></h4>
<div class="description">
De-registers an event listener from an event name.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<