UNPKG

qminer

Version:

A C++ based data analytics platform for processing large-scale real-time streams containing structured and unstructured data

462 lines (457 loc) 19.9 kB
<!doctype html> <html> <head> <meta name="generator" content="JSDoc 3"> <meta charset="utf-8"> <title>Class: Record</title> <link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Karla:400,400i,700,700i" type="text/css"> <link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Noto+Serif:400,400i,700,700i" type="text/css"> <link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css"> <link href="css/baseline.css" rel="stylesheet"> </head> <body onload="prettyPrint()"> <nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar"> <div id="jsdoc-navbar-container"> <div id="jsdoc-navbar-content"> <a href="index.html" class="jsdoc-navbar-package-name">QMiner JavaScript API v9.4.0</a> </div> </div> </nav> <div id="jsdoc-body-container"> <div id="jsdoc-content"> <div id="jsdoc-content-container"> <div id="jsdoc-main" role="main"> <header class="page-header"> <div class="symbol-detail-labels"><span class="label label-kind">class</span>&nbsp;<span class="label label-static">static</span></div> <h1><small><a href="module-qm.html">qm</a>.<wbr></small><span class="symbol-name">Record</span></h1> <p class="source-link">Source: <a href="qminerdoc.js.html#source-line-1460">qminerdoc.<wbr>js:1460</a></p> <dl class="dl-compact"> </dl> </header> <section id="summary"> <div class="summary-callout"> <h2 class="summary-callout-heading">Properties</h2> <div class="summary-content"> <div class="summary-column"> <dl class="dl-summary-callout"> <dt><a href="module-qm.Record.html#$fq">$fq</a></dt> <dd> </dd> <dt><a href="module-qm.Record.html#$id">$id</a></dt> <dd> </dd> </dl> </div> <div class="summary-column"> <dl class="dl-summary-callout"> <dt><a href="module-qm.Record.html#$name">$name</a></dt> <dd> </dd> <dt><a href="module-qm.Record.html#store">store</a></dt> <dd> </dd> </dl> </div> <div class="summary-column"> </div> </div> </div> <div class="summary-callout"> <h2 class="summary-callout-heading">Methods</h2> <div class="summary-content"> <div class="summary-column"> <dl class="dl-summary-callout"> <dt><a href="module-qm.Record.html#$addJoin">$addJoin(joinName, joinRecord[, joinFrequency])</a></dt> <dd> </dd> <dt><a href="module-qm.Record.html#$clone">$clone()</a></dt> <dd> </dd> </dl> </div> <div class="summary-column"> <dl class="dl-summary-callout"> <dt><a href="module-qm.Record.html#$delJoin">$delJoin(joinName, joinRecord[, joinFrequency])</a></dt> <dd> </dd> <dt><a href="module-qm.Record.html#toJSON">toJSON([joinRecords][, joinRecordFields][, sysFields])</a></dt> <dd> </dd> </dl> </div> <div class="summary-column"> </div> </div> </div> </section> <section> <h2 id="Record"><span class="symbol-name">Record</span><span class="signature"><span class="signature-params">()</span></span></h2> <p>Records are used for storing data in <a href="module-qm.Store.html">module:qm.Store</a>. <br> <b>Factory pattern</b>: this class cannot be construced using the new keyword. This class is constructed when calling a specific method or attribute, e.g. using <a href="module-qm.Store.html#push">module:qm.Store#push</a> to create a new record in the store or <a href="module-qm.Store.html#newRecord">module:qm.Store#newRecord</a> to create a new record, that is not saved in the store. </p> <dl class="dl-compact"> </dl> </section> <section> <h2>Properties</h2> <section> <h3 id="$fq"><span class="symbol-name">$fq</span></h3> <p>Returns the frequency of the record. Type <code>number</code>.</p> <dl class="dl-compact"> </dl> <h3 id="$id"><span class="symbol-name">$id</span></h3> <p>Returns the id of the record. Type <code>number</code>.</p> <dl class="dl-compact"> </dl> <h3 id="$name"><span class="symbol-name">$name</span></h3> <p>Returns the name of the record. Type <code>string</code>.</p> <dl class="dl-compact"> </dl> <h3 id="store"><span class="symbol-name">store</span></h3> <p>Returns the store the record belongs to. Type <a href="module-qm.Store.html">module:qm.Store</a>.</p> <dl class="dl-compact"> </dl> </section> <h2>Methods</h2> <section> <h3 id="$addJoin"><span class="symbol-name">$addJoin</span><span class="signature"><span class="signature-params">(joinName, joinRecord[, joinFrequency])</span>&nbsp;&rarr; <span class="signature-returns"> <a href="module-qm.Record.html">module:qm.Record</a></span></span></h3> <p>Adds a join record <code>joinRecord</code> to join <code>joinName</code> (string) with join frequency <code>joinFrequency</code>.</p> <section> <h4> Example </h4> <div> <pre class="prettyprint"><code>// import qm module var qm &#x3D; require(&#x27;qminer&#x27;); // Create two stores var base &#x3D; new qm.Base({ mode: &#x27;createClean&#x27;, schema: [ { name: &#x27;People&#x27;, fields: [{ name: &#x27;name&#x27;, type: &#x27;string&#x27;, primary: true }], joins: [{ name: &#x27;directed&#x27;, &#x27;type&#x27;: &#x27;index&#x27;, &#x27;store&#x27;: &#x27;Movies&#x27;, &#x27;inverse&#x27;: &#x27;director&#x27; }] }, { name: &#x27;Movies&#x27;, fields: [{ name: &#x27;title&#x27;, type: &#x27;string&#x27;, primary: true }], joins: [{ name: &#x27;director&#x27;, &#x27;type&#x27;: &#x27;field&#x27;, &#x27;store&#x27;: &#x27;People&#x27;, &#x27;inverse&#x27;: &#x27;directed&#x27; }] } ] }); // Add a record to people and a record to movies base.store(&#x27;Movies&#x27;).push({ title: &#x27;Coffee and Cigarettes&#x27; }); base.store(&#x27;People&#x27;).push({ name: &#x27;Jim Jarmusch&#x27; }); // add a join between the added records base.store(&#x27;People&#x27;)[0].$addJoin(&#x27;directed&#x27;, base.store(&#x27;Movies&#x27;)[0]); base.close();</code></pre> </div> </section> <section> <h4>Parameters</h4> <table class="jsdoc-details-table"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Optional</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td> <p>joinName</p> </td> <td> <p>string</p> </td> <td> <p>&nbsp;</p> </td> <td> <p>Join name.</p> </td> </tr> <tr> <td> <p>joinRecord</p> </td> <td> <p>(<a href="module-qm.Record.html">module:qm.Record</a> or number)</p> </td> <td> <p>&nbsp;</p> </td> <td> <p>Joined record or its ID.</p> </td> </tr> <tr> <td> <p>joinFrequency</p> </td> <td> <p>number</p> </td> <td> <p>Yes</p> </td> <td> <p>Frequency attached to the join.</p> <p>Defaults to <code>1</code>.</p> </td> </tr> </tbody> </table> </section> <dl class="dl-compact"> <dt>Returns</dt> <dd> <p><code><a href="module-qm.Record.html">module:qm.Record</a></code>B The joined record.</p> </dd> </dl> <h3 id="$clone"><span class="symbol-name">$clone</span><span class="signature"><span class="signature-params">()</span>&nbsp;&rarr; <span class="signature-returns"> <a href="module-qm.Record.html">module:qm.Record</a></span></span></h3> <p>Clones the record.</p> <section> <h4> Example </h4> <div> <pre class="prettyprint"><code>// import qm module var qm &#x3D; require(&#x27;qminer&#x27;); // create a new base containing one store var base &#x3D; new qm.Base({ mode: &quot;createClean&quot;, schema: [{ name: &quot;StarWarsMovies&quot;, fields: [ { name: &quot;Title&quot;, type: &quot;string&quot; }, { name: &quot;ReleseDate&quot;, type: &quot;datetime&quot; }, { name: &quot;Length&quot;, type: &quot;int&quot; } ] }] }); // create some records in the new store base.store(&quot;StarWarsMovies&quot;).push({ Title: &quot;Attack of the Clones&quot;, ReleseDate: &quot;2002-05-16T00:00:00&quot;, Length: 142 }); base.store(&quot;StarWarsMovies&quot;).push({ Title: &quot;The Empire Strikes Back&quot;, ReleseDate: &quot;1980-06-20T00:00:00&quot;, Length: 124 }); base.store(&quot;StarWarsMovies&quot;).push({ Title: &quot;Return of the Jedi&quot;, ReleseDate: &quot;1983-05-25T00:00:00&quot;, Length: 134 }); // create a clone of the &quot;Attack of the Clones&quot; record var clone &#x3D; base.store(&quot;StarWarsMovies&quot;)[0].$clone(); base.close();</code></pre> </div> </section> <dl class="dl-compact"> <dt>Returns</dt> <dd> <p><code><a href="module-qm.Record.html">module:qm.Record</a></code>B The clone of the record.</p> </dd> </dl> <h3 id="$delJoin"><span class="symbol-name">$delJoin</span><span class="signature"><span class="signature-params">(joinName, joinRecord[, joinFrequency])</span>&nbsp;&rarr; <span class="signature-returns"> <a href="module-qm.Record.html">module:qm.Record</a></span></span></h3> <p>Deletes join record <code>joinRecord</code> from join <code>joinName</code> (string) with join frequency <code>joinFrequency</code>.</p> <section> <h4> Example </h4> <div> <pre class="prettyprint"><code>// import qm module var qm &#x3D; require(&#x27;qminer&#x27;); // Create two stores var base &#x3D; new qm.Base({ mode: &#x27;createClean&#x27;, schema: [ { name: &#x27;People&#x27;, fields: [{ name: &#x27;name&#x27;, type: &#x27;string&#x27;, primary: true }], joins: [{ name: &#x27;directed&#x27;, &#x27;type&#x27;: &#x27;index&#x27;, &#x27;store&#x27;: &#x27;Movies&#x27;, &#x27;inverse&#x27;: &#x27;director&#x27; }] }, { name: &#x27;Movies&#x27;, fields: [{ name: &#x27;title&#x27;, type: &#x27;string&#x27;, primary: true }], joins: [{ name: &#x27;director&#x27;, &#x27;type&#x27;: &#x27;field&#x27;, &#x27;store&#x27;: &#x27;People&#x27;, &#x27;inverse&#x27;: &#x27;directed&#x27; }] } ] }); // Add a record to people and a record to movies base.store(&#x27;Movies&#x27;).push({ title: &#x27;Coffee and Cigarettes&#x27;, director: { name: &#x27;Jim Jarmusch&#x27; } }); // delete the join between the added records base.store(&#x27;People&#x27;)[0].$delJoin(&#x27;directed&#x27;, base.store(&#x27;Movies&#x27;)[0]); base.close();</code></pre> </div> </section> <section> <h4>Parameters</h4> <table class="jsdoc-details-table"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Optional</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td> <p>joinName</p> </td> <td> <p>string</p> </td> <td> <p>&nbsp;</p> </td> <td> <p>Join name.</p> </td> </tr> <tr> <td> <p>joinRecord</p> </td> <td> <p>(<a href="module-qm.Record.html">module:qm.Record</a> or number)</p> </td> <td> <p>&nbsp;</p> </td> <td> <p>Joined record or its ID.</p> </td> </tr> <tr> <td> <p>joinFrequency</p> </td> <td> <p>number</p> </td> <td> <p>Yes</p> </td> <td> <p>Frequency attached to the join.</p> <p>Defaults to <code>1</code>.</p> </td> </tr> </tbody> </table> </section> <dl class="dl-compact"> <dt>Returns</dt> <dd> <p><code><a href="module-qm.Record.html">module:qm.Record</a></code>B The joined record.</p> </dd> </dl> <h3 id="toJSON"><span class="symbol-name">toJSON</span><span class="signature"><span class="signature-params">([joinRecords][, joinRecordFields][, sysFields])</span>&nbsp;&rarr; <span class="signature-returns"> Object</span></span></h3> <p>Creates a JSON version of the record.</p> <section> <h4> Example </h4> <div> <pre class="prettyprint"><code>// import qm module var qm &#x3D; require(&#x27;qminer&#x27;); // create a new base containing one store var base &#x3D; new qm.Base({ mode: &quot;createClean&quot;, schema: [{ name: &quot;Musicians&quot;, fields: [ { name: &quot;Name&quot;, type: &quot;string&quot;, primary: true }, { name: &quot;DateOfBirth&quot;, type: &quot;datetime&quot; }, { name: &quot;GreatestHits&quot;, type: &quot;string_v&quot; } ] }] }); // create some records base.store(&quot;Musicians&quot;).push({ Name: &quot;Jimmy Page&quot;, DateOfBirth: &quot;1944-01-09T00:00:00&quot;, GreatestHits: [&quot;Stairway to Heaven&quot;, &quot;Whole Lotta Love&quot;] }); base.store(&quot;Musicians&quot;).push({ Name: &quot;Beyonce&quot;, DateOfBirth: &quot;1981-09-04T00:00:00&quot;, GreatestHits: [&quot;Single Ladies (Put a Ring on It)&quot;] }); // get a JSON version of the &quot;Beyonce&quot; record // The JSON object for this example si: // { &#x27;$id&#x27;: 1, Name: &#x27;Beyonce&#x27;, ActiveSince: &#x27;1981-09-04T00:00:00&#x27;, GreatestHits: [&#x27;Single Ladies (Put a Ring on It)&#x27;] } var json &#x3D; base.store(&quot;Musicians&quot;).recordByName(&quot;Beyonce&quot;).toJSON(); base.close();</code></pre> </div> </section> <section> <h4>Parameters</h4> <table class="jsdoc-details-table"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Optional</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td> <p>joinRecords</p> </td> <td> <p>Boolean</p> </td> <td> <p>Yes</p> </td> <td> <p>Include joined records (only IDs).</p> <p>Defaults to <code>false</code>.</p> </td> </tr> <tr> <td> <p>joinRecordFields</p> </td> <td> <p>Boolean</p> </td> <td> <p>Yes</p> </td> <td> <p>Expand joined record fields.</p> <p>Defaults to <code>false</code>.</p> </td> </tr> <tr> <td> <p>sysFields</p> </td> <td> <p>Boolean</p> </td> <td> <p>Yes</p> </td> <td> <p>If set to true system fields, like $id, will be included.</p> <p>Defaults to <code>true</code>.</p> </td> </tr> </tbody> </table> </section> <dl class="dl-compact"> <dt>Returns</dt> <dd> <p><code>Object</code>B The JSON version of the record.</p> </dd> </dl> </section> </section> </div> </div> <nav id="jsdoc-toc-nav" role="navigation"></nav> </div> </div> <footer id="jsdoc-footer" class="jsdoc-footer"> <div id="jsdoc-footer-container"> <p> </p> </div> </footer> <script src="scripts/jquery.min.js"></script> <script src="scripts/tree.jquery.js"></script> <script src="scripts/prettify.js"></script> <script src="scripts/jsdoc-toc.js"></script> <script src="scripts/linenumber.js"></script> <script src="scripts/scrollanchor.js"></script> </body> </html>