trilium/docs/backend_api/module-sql.html

1267 lines
15 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Module: sql</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">Module: sql</h1>
<section>
<header>
</header>
<article>
<div class="container-overview">
</div>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id=".execute"><span class="type-signature">(static) </span>execute<span class="signature">(query, params<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
<div class="description">
Execute SQL
</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">string</span>
</td>
<td class="attributes">
</td>
<td class="description last">SQL query with ? used as parameter placeholder</td>
</tr>
<tr>
<td class="name"><code>params</code></td>
<td class="type">
<span class="param-type">Array.&lt;object></span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last">array of params if needed</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_sql.js.html">services/sql.js</a>, <a href="services_sql.js.html#line352">line 352</a>
</li></ul></dd>
</dl>
<h4 class="name" id=".getColumn"><span class="type-signature">(static) </span>getColumn<span class="signature">(query, params<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Array.&lt;object>}</span></h4>
<div class="description">
Get a first column 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>query</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
</td>
<td class="description last">SQL query with ? used as parameter placeholder</td>
</tr>
<tr>
<td class="name"><code>params</code></td>
<td class="type">
<span class="param-type">Array.&lt;object></span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last">array of params if needed</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_sql.js.html">services/sql.js</a>, <a href="services_sql.js.html#line343">line 343</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- array of first column of all returned rows
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.&lt;object></span>
</dd>
</dl>
<h4 class="name" id=".getMap"><span class="type-signature">(static) </span>getMap<span class="signature">(query, params<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {object}</span></h4>
<div class="description">
Get a map of first column mapping to second column.
</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">string</span>
</td>
<td class="attributes">
</td>
<td class="description last">SQL query with ? used as parameter placeholder</td>
</tr>
<tr>
<td class="name"><code>params</code></td>
<td class="type">
<span class="param-type">Array.&lt;object></span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last">array of params if needed</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_sql.js.html">services/sql.js</a>, <a href="services_sql.js.html#line333">line 333</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- map of first column to second column
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">object</span>
</dd>
</dl>
<h4 class="name" id=".getRow"><span class="type-signature">(static) </span>getRow<span class="signature">(query, params<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {object}</span></h4>
<div class="description">
Get first returned row.
</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">string</span>
</td>
<td class="attributes">
</td>
<td class="description last">SQL query with ? used as parameter placeholder</td>
</tr>
<tr>
<td class="name"><code>params</code></td>
<td class="type">
<span class="param-type">Array.&lt;object></span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last">array of params if needed</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_sql.js.html">services/sql.js</a>, <a href="services_sql.js.html#line309">line 309</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- map of column name to column value
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">object</span>
</dd>
</dl>
<h4 class="name" id=".getRows"><span class="type-signature">(static) </span>getRows<span class="signature">(query, params<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Array.&lt;object>}</span></h4>
<div class="description">
Get all returned rows.
</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">string</span>
</td>
<td class="attributes">
</td>
<td class="description last">SQL query with ? used as parameter placeholder</td>
</tr>
<tr>
<td class="name"><code>params</code></td>
<td class="type">
<span class="param-type">Array.&lt;object></span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last">array of params if needed</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_sql.js.html">services/sql.js</a>, <a href="services_sql.js.html#line320">line 320</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- array of all rows, each row is a map of column name to column value
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.&lt;object></span>
</dd>
</dl>
<h4 class="name" id=".getValue"><span class="type-signature">(static) </span>getValue<span class="signature">(query, params<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
<div class="description">
Get single value from the given query - first column from first returned row.
</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">string</span>
</td>
<td class="attributes">
</td>
<td class="description last">SQL query with ? used as parameter placeholder</td>
</tr>
<tr>
<td class="name"><code>params</code></td>
<td class="type">
<span class="param-type">Array.&lt;object></span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last">array of params if needed</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_sql.js.html">services/sql.js</a>, <a href="services_sql.js.html#line299">line 299</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
[object] - single value
</div>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-sql.html">sql</a></li></ul><h3>Classes</h3><ul><li><a href="ApiToken.html">ApiToken</a></li><li><a href="Attribute.html">Attribute</a></li><li><a href="BackendScriptApi.html">BackendScriptApi</a></li><li><a href="Branch.html">Branch</a></li><li><a href="Note.html">Note</a></li><li><a href="NoteRevision.html">NoteRevision</a></li><li><a href="Option.html">Option</a></li><li><a href="RecentNote.html">RecentNote</a></li></ul><h3><a href="global.html">Global</a></h3>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.7</a>
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>