forerunnerdb
Version:
A NoSQL document store database for browsers and Node.js.
2,140 lines (538 loc) • 27.1 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Class: Core</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: Core</h1>
<section>
<header>
<h2>Core</h2>
</header>
<article>
<div class="container-overview">
<h4 class="name" id="Core"><span class="type-signature"></span>new Core<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
Creates a new ForerunnerDB instance. Core instances handle the lifecycle of
multiple database instances.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Core.js.html">Core.js</a>, <a href="Core.js.html#line27">line 27</a>
</li></ul></dd>
</dl>
</div>
<h3 class="subsection-title">Methods</h3>
<ul><li><a href="#moduleLoaded"><span class="type-signature">(static) </span>moduleLoaded<span class="signature">(moduleName, callback)</span><span class="type-signature"></span></a></li><li><a href="#moduleLoaded"><span class="type-signature">(static) </span>moduleLoaded<span class="signature">(moduleName, callback)</span><span class="type-signature"></span></a></li><li><a href="#moduleLoaded"><span class="type-signature">(static) </span>moduleLoaded<span class="signature">(moduleName, success, failure)</span><span class="type-signature"></span></a></li><li><a href="#moduleLoaded"><span class="type-signature">(static) </span>moduleLoaded<span class="signature">(moduleName)</span><span class="type-signature"> → {Boolean}</span></a></li><li><a href="#collection"><span class="type-signature"></span>collection<span class="signature">()</span><span class="type-signature"></span></a></li><li><a href="#databases"><span class="type-signature"></span>databases<span class="signature">(search)</span><span class="type-signature"> → {Array}</span></a></li><li><a href="#db"><span class="type-signature"></span>db<span class="signature">(name<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {<a href="Db.html">Db</a>}</span></a></li><li><a href="#init"><span class="type-signature"></span>init<span class="signature">()</span><span class="type-signature"> → {*}</span></a></li><li><a href="#instances"><span class="type-signature"></span>instances<span class="signature">(index<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Array|Object}</span></a></li><li><a href="#instantiatedCount"><span class="type-signature"></span>instantiatedCount<span class="signature">()</span><span class="type-signature"> → {Number}</span></a></li><li><a href="#isClient"><span class="type-signature"></span>isClient<span class="signature">()</span><span class="type-signature"> → {Boolean}</span></a></li><li><a href="#isServer"><span class="type-signature"></span>isServer<span class="signature">()</span><span class="type-signature"> → {Boolean}</span></a></li><li><a href="#namedInstances"><span class="type-signature"></span>namedInstances<span class="signature">(name<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Array|Object}</span></a></li><li><a href="#version"><span class="type-signature"></span>version<span class="signature">(val, callback)</span><span class="type-signature"> → {Boolean}</span></a></li></ul>
<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">function</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="Core.js.html">Core.js</a>, <a href="Core.js.html#line117">line 117</a>
</li></ul></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 an array of named modules are 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">Array</span>
</td>
<td class="description last">The array of module names to check for.</td>
</tr>
<tr>
<td class="name"><code>callback</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="description last">The callback method to call if modules are loaded.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Core.js.html">Core.js</a>, <a href="Core.js.html#line142">line 142</a>
</li></ul></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">function</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">function</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="Core.js.html">Core.js</a>, <a href="Core.js.html#line174">line 174</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="Core.js.html">Core.js</a>, <a href="Core.js.html#line91">line 91</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="collection"><span class="type-signature"></span>collection<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
Added to provide an error message for users who have not seen
the new instantiation breaking change warning and try to get
a collection directly from the core instance.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Core.js.html">Core.js</a>, <a href="Core.js.html#line286">line 286</a>
</li></ul></dd>
</dl>
<h4 class="name" id="databases"><span class="type-signature"></span>databases<span class="signature">(search)</span><span class="type-signature"> → {Array}</span></h4>
<div class="description">
Returns an array of databases that ForerunnerDB 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="Db.js.html">Db.js</a>, <a href="Db.js.html#line540">line 540</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
An array of objects containing details of each database
that ForerunnerDB is currently managing and it's child entities.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array</span>
</dd>
</dl>
<h4 class="name" id="db"><span class="type-signature"></span>db<span class="signature">(name<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {<a href="Db.html">Db</a>}</span></h4>
<div class="description">
Gets a database instance by name.
</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>name</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 database. If none is provided
a random name is assigned.</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#line515">line 515</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="Db.html">Db</a></span>
</dd>
</dl>
<h4 class="name" id="init"><span class="type-signature"></span>init<span class="signature">()</span><span class="type-signature"> → {*}</span></h4>
<div class="description">
Override the Core init to instantiate the plugin.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="NodeApiServer.js.html">NodeApiServer.js</a>, <a href="NodeApiServer.js.html#line914">line 914</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">*</span>
</dd>
</dl>
<h4 class="name" id="instances"><span class="type-signature"></span>instances<span class="signature">(index<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Array|Object}</span></h4>
<div class="description">
Get all instances as an array or a single ForerunnerDB instance
by it's array index.
</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>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 of instance to get.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Core.js.html">Core.js</a>, <a href="Core.js.html#line53">line 53</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Array of instances or a single instance.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array</span>
|
<span class="param-type">Object</span>
</dd>
</dl>
<h4 class="name" id="instantiatedCount"><span class="type-signature"></span>instantiatedCount<span class="signature">()</span><span class="type-signature"> → {Number}</span></h4>
<div class="description">
Returns the number of instantiated ForerunnerDB objects.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Core.js.html">Core.js</a>, <a href="Core.js.html#line43">line 43</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
The number of instantiated instances.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Number</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="Core.js.html">Core.js</a>, <a href="Core.js.html#line268">line 268</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"> → {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="Core.js.html">Core.js</a>, <a href="Core.js.html#line277">line 277</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="namedInstances"><span class="type-signature"></span>namedInstances<span class="signature">(name<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Array|Object}</span></h4>
<div class="description">
Get all instances as an array of instance names or a single ForerunnerDB
instance by it's name.
</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>name</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 instance to get.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Core.js.html">Core.js</a>, <a href="Core.js.html#line67">line 67</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Array of instance names or a single instance.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array</span>
|
<span class="param-type">Object</span>
</dd>
</dl>
<h4 class="name" id="version"><span class="type-signature"></span>version<span class="signature">(val, callback)</span><span class="type-signature"> → {Boolean}</span></h4>
<div class="description">
Checks version against the string passed and if it matches (or partially matches)
then the callback is called.
</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>val</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">The version to check against.</td>
</tr>
<tr>
<td class="name"><code>callback</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="description last">The callback to call if match is true.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Core.js.html">Core.js</a>, <a href="Core.js.html#line209">line 209</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Boolean</span>
</dd>
</dl>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="ActiveBucket.html">ActiveBucket</a></li><li><a href="Angular.html">Angular</a></li><li><a href="AutoBind.html">AutoBind</a></li><li><a href="Collection.html">Collection</a></li><li><a href="CollectionGroup.html">CollectionGroup</a></li><li><a href="Condition.html">Condition</a></li><li><a href="Core.html">Core</a></li><li><a href="Db.html">Db</a></li><li><a href="Document.html">Document</a></li><li><a href="Grid.html">Grid</a></li><li><a href="Highchart.html">Highchart</a></li><li><a href="Index2d.html">Index2d</a></li><li><a href="IndexBinaryTree.html">IndexBinaryTree</a></li><li><a href="IndexHashMap.html">IndexHashMap</a></li><li><a href="Infinilist.html">Infinilist</a></li><li><a href="KeyValueStore.html">KeyValueStore</a></li><li><a href="Metrics.html">Metrics</a></li><li><a href="MyModule.html">MyModule</a></li><li><a href="NodeApiClient.html">NodeApiClient</a></li><li><a href="NodeApiServer.html">NodeApiServer</a></li><li><a href="NodeRAS.html">NodeRAS</a></li><li><a href="Odm.html">Odm</a></li><li><a href="OldView.html">OldView</a></li><li><a href="Operation.html">Operation</a></li><li><a href="Overload.html">Overload</a></li><li><a href="Overview.html">Overview</a></li><li><a href="Overview_init.html">init</a></li><li><a href="Path.html">Path</a></li><li><a href="Persist.html">Persist</a></li><li><a href="Procedure.html">Procedure</a></li><li><a href="ReactorIO.html">ReactorIO</a></li><li><a href="Section.html">Section</a></li><li><a href="Serialiser.html">Serialiser</a></li><li><a href="Shared.overload.html">overload</a></li><li><a href="View.html">View</a></li></ul><h3>Mixins</h3><ul><li><a href="ChainReactor.html">ChainReactor</a></li><li><a href="Common.html">Common</a></li><li><a href="Constants.html">Constants</a></li><li><a href="Events.html">Events</a></li><li><a href="Matching.html">Matching</a></li><li><a href="Shared.html">Shared</a></li><li><a href="Sorting.html">Sorting</a></li><li><a href="Tags.html">Tags</a></li><li><a href="Triggers.html">Triggers</a></li><li><a href="Updating.html">Updating</a></li></ul><h3><a href="global.html">Global</a></h3>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Thu Mar 01 2018 11:34:22 GMT+0000 (GMT)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>