Skip to content

Build your personal knowledge base with Trilium Notes

add backend API methods to access options, attachments, revisions, etapi tokens

zadam7d80fe19e020
diff --git a/docs/backend_api/BackendScriptApi.html b/docs/backend_api/BackendScriptApi.html
index c3924360a9..5618ff0d92 100644
--- a/docs/backend_api/BackendScriptApi.html
+++ b/docs/backend_api/BackendScriptApi.html
@@ -94,7 +94,7 @@ available in the JS backend notes. You can use e.g. <code>api.log(api.startNote.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line42">line 42</a>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line43">line 43</a>
</li></ul></dd>
@@ -240,7 +240,7 @@ available in the JS backend notes. You can use e.g. <code>api.log(api.startNote.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line623">line 623</a>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line671">line 671</a>
</li></ul></dd>
@@ -314,7 +314,7 @@ available in the JS backend notes. You can use e.g. <code>api.log(api.startNote.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line68">line 68</a>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line69">line 69</a>
</li></ul></dd>
@@ -386,7 +386,7 @@ available in the JS backend notes. You can use e.g. <code>api.log(api.startNote.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line52">line 52</a>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line53">line 53</a>
</li></ul></dd>
@@ -458,7 +458,7 @@ available in the JS backend notes. You can use e.g. <code>api.log(api.startNote.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line73">line 73</a>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line74">line 74</a>
</li></ul></dd>
@@ -530,7 +530,7 @@ available in the JS backend notes. You can use e.g. <code>api.log(api.startNote.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line57">line 57</a>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line58">line 58</a>
</li></ul></dd>
@@ -602,7 +602,7 @@ available in the JS backend notes. You can use e.g. <code>api.log(api.startNote.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line467">line 467</a>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line515">line 515</a>
</li></ul></dd>
@@ -674,7 +674,7 @@ available in the JS backend notes. You can use e.g. <code>api.log(api.startNote.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line47">line 47</a>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line48">line 48</a>
</li></ul></dd>
@@ -746,7 +746,7 @@ available in the JS backend notes. You can use e.g. <code>api.log(api.startNote.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line78">line 78</a>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line79">line 79</a>
</li></ul></dd>
@@ -922,7 +922,7 @@ JSON MIME type. See also createNewNote() for more options.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line227">line 227</a>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line275">line 275</a>
</li></ul></dd>
@@ -1441,7 +1441,7 @@ JSON MIME type. See also createNewNote() for more options.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line250">line 250</a>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line298">line 298</a>
</li></ul></dd>
@@ -2075,7 +2075,7 @@ JSON MIME type. See also createNewNote() for more options.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line270">line 270</a>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line318">line 318</a>
</li></ul></dd>
@@ -2602,7 +2602,7 @@ JSON MIME type. See also createNewNote() for more options.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line494">line 494</a>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line542">line 542</a>
</li></ul></dd>
@@ -2803,7 +2803,7 @@ JSON MIME type. See also createNewNote() for more options.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line210">line 210</a>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line258">line 258</a>
</li></ul></dd>
@@ -2985,7 +2985,7 @@ JSON MIME type. See also createNewNote() for more options.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line187">line 187</a>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line235">line 235</a>
</li></ul></dd>
@@ -3186,7 +3186,7 @@ JSON MIME type. See also createNewNote() for more options.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line177">line 177</a>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line225">line 225</a>
</li></ul></dd>
@@ -3337,7 +3337,7 @@ JSON MIME type. See also createNewNote() for more options.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line454">line 454</a>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line502">line 502</a>
</li></ul></dd>
@@ -3538,7 +3538,7 @@ JSON MIME type. See also createNewNote() for more options.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line560">line 560</a>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line608">line 608</a>
</li></ul></dd>
@@ -3640,7 +3640,7 @@ JSON MIME type. See also createNewNote() for more options.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line473">line 473</a>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line521">line 521</a>
</li></ul></dd>
@@ -3701,7 +3701,7 @@ JSON MIME type. See also createNewNote() for more options.
- <h4 class="name" id="getAttribute"><span class="type-signature"></span>getAttribute<span class="signature">(attributeId)</span><span class="type-signature"> &rarr; {<a href="BAttribute.html">BAttribute</a>|null}</span></h4>
+ <h4 class="name" id="getAttachment"><span class="type-signature"></span>getAttachment<span class="signature">(attachmentId)</span><span class="type-signature"> &rarr; {<a href="BAttachment.html">BAttachment</a>|null}</span></h4>
@@ -3741,7 +3741,7 @@ JSON MIME type. See also createNewNote() for more options.
<tr>
- <td class="name"><code>attributeId</code></td>
+ <td class="name"><code>attachmentId</code></td>
<td class="type">
@@ -3798,7 +3798,7 @@ JSON MIME type. See also createNewNote() for more options.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line107">line 107</a>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line115">line 115</a>
</li></ul></dd>
@@ -3834,7 +3834,7 @@ JSON MIME type. See also createNewNote() for more options.
</dt>
<dd>
-<span class="param-type"><a href="BAttribute.html">BAttribute</a></span>
+<span class="param-type"><a href="BAttachment.html">BAttachment</a></span>
|
<span class="param-type">null</span>
@@ -3855,7 +3855,7 @@ JSON MIME type. See also createNewNote() for more options.
- <h4 class="name" id="getBranch"><span class="type-signature"></span>getBranch<span class="signature">(branchId)</span><span class="type-signature"> &rarr; {<a href="BBranch.html">BBranch</a>|null}</span></h4>
+ <h4 class="name" id="getAttribute"><span class="type-signature"></span>getAttribute<span class="signature">(attributeId)</span><span class="type-signature"> &rarr; {<a href="BAttribute.html">BAttribute</a>|null}</span></h4>
@@ -3895,7 +3895,7 @@ JSON MIME type. See also createNewNote() for more options.
<tr>
- <td class="name"><code>branchId</code></td>
+ <td class="name"><code>attributeId</code></td>
<td class="type">
@@ -3952,7 +3952,7 @@ JSON MIME type. See also createNewNote() for more options.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line100">line 100</a>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line108">line 108</a>
</li></ul></dd>
@@ -3988,7 +3988,7 @@ JSON MIME type. See also createNewNote() for more options.
</dt>
<dd>
-<span class="param-type"><a href="BBranch.html">BBranch</a></span>
+<span class="param-type"><a href="BAttribute.html">BAttribute</a></span>
|
<span class="param-type">null</span>
@@ -4009,17 +4009,13 @@ JSON MIME type. See also createNewNote() for more options.
- <h4 class="name" id="getDayNote"><span class="type-signature"></span>getDayNote<span class="signature">(date, rootNote<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {<a href="BNote.html">BNote</a>|null}</span></h4>
+ <h4 class="name" id="getAttribute"><span class="type-signature"></span>getAttribute<span class="signature">(attributeId)</span><span class="type-signature"> &rarr; {<a href="BAttribute.html">BAttribute</a>|null}</span></h4>
-<div class="description">
- Returns day note for given date. If such note doesn't exist, it is created.
-</div>
-
@@ -4041,8 +4037,6 @@ JSON MIME type. See also createNewNote() for more options.
<th>Type</th>
- <th>Attributes</th>
-
@@ -4055,7 +4049,7 @@ JSON MIME type. See also createNewNote() for more options.
<tr>
- <td class="name"><code>date</code></td>
+ <td class="name"><code>attributeId</code></td>
<td class="type">
@@ -4068,51 +4062,164 @@ JSON MIME type. See also createNewNote() for more options.
</td>
- <td class="attributes">
-
-
-
-
- </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="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line155">line 155</a>
+ </li></ul></dd>
+
+
+
+
+
+
+
+</dl>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<h5>Returns:</h5>
+
+
+
+
+<dl>
+ <dt>
+ Type
+ </dt>
+ <dd>
+
+<span class="param-type"><a href="BAttribute.html">BAttribute</a></span>
+|
+
+<span class="param-type">null</span>
+
+
+ </dd>
+</dl>
+
+
+
+
+
+
+
+
- <td class="description last">in YYYY-MM-DD format</td>
- </tr>
+
+
+
+ <h4 class="name" id="getBranch"><span class="type-signature"></span>getBranch<span class="signature">(branchId)</span><span class="type-signature"> &rarr; {<a href="BBranch.html">BBranch</a>|null}</span></h4>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <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>rootNote</code></td>
+ <td class="name"><code>branchId</code></td>
<td class="type">
-<span class="param-type"><a href="BNote.html">BNote</a></span>
+<span class="param-type">string</span>
</td>
- <td class="attributes">
-
- &lt;optional><br>
-
-
-
-
-
- </td>
-
- <td class="description last">specify calendar root note, normally leave empty to use the default calendar</td>
+ <td class="description last"></td>
</tr>
@@ -4153,7 +4260,7 @@ JSON MIME type. See also createNewNote() for more options.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line353">line 353</a>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line101">line 101</a>
</li></ul></dd>
@@ -4182,52 +4289,1065 @@ JSON MIME type. See also createNewNote() for more options.
-
-<dl>
- <dt>
- Type
- </dt>
- <dd>
+
+<dl>
+ <dt>
+ Type
+ </dt>
+ <dd>
+
+<span class="param-type"><a href="BBranch.html">BBranch</a></span>
+|
+
+<span class="param-type">null</span>
+
+
+ </dd>
+</dl>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <h4 class="name" id="getDayNote"><span class="type-signature"></span>getDayNote<span class="signature">(date, rootNote<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {<a href="BNote.html">BNote</a>|null}</span></h4>
+
+
+
+
+
+
+<div class="description">
+ Returns day note for given date. If such note doesn't exist, it is created.
+</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>date</code></td>
+
+
+ <td class="type">
+
+
+<span class="param-type">string</span>
+
+
+
+ </td>
+
+
+ <td class="attributes">
+
+
+
+
+
+ </td>
+
+
+
+
+ <td class="description last">in YYYY-MM-DD format</td>
+ </tr>
+
+
+
+ <tr>
+
+ <td class="name"><code>rootNote</code></td>
+
+
+ <td class="type">
+
+
+<span class="param-type"><a href="BNote.html">BNote</a></span>
+
+
+
+ </td>
+
+
+ <td class="attributes">
+
+ &lt;optional><br>
+
+
+
+
+
+ </td>
+
+
+
+
+ <td class="description last">specify calendar root note, normally leave empty to use the default calendar</td>
+ </tr>
+
+
+ </tbody>
+</table>
+
+
+
+
+
+
+<dl class="details">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <dt class="tag-source">Source:</dt>
+ <dd class="tag-source"><ul class="dummy"><li>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line401">line 401</a>
+ </li></ul></dd>
+
+
+
+
+
+
+
+</dl>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<h5>Returns:</h5>
+
+
+
+
+<dl>
+ <dt>
+ Type
+ </dt>
+ <dd>
+
+<span class="param-type"><a href="BNote.html">BNote</a></span>
+|
+
+<span class="param-type">null</span>
+
+
+ </dd>
+</dl>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <h4 class="name" id="getEtapiToken"><span class="type-signature"></span>getEtapiToken<span class="signature">(etapiTokenId)</span><span class="type-signature"> &rarr; {<a href="BEtapiToken.html">BEtapiToken</a>|null}</span></h4>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <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>etapiTokenId</code></td>
+
+
+ <td class="type">
+
+
+<span class="param-type">string</span>
+
+
+
+ </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="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line129">line 129</a>
+ </li></ul></dd>
+
+
+
+
+
+
+
+</dl>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<h5>Returns:</h5>
+
+
+
+
+<dl>
+ <dt>
+ Type
+ </dt>
+ <dd>
+
+<span class="param-type"><a href="BEtapiToken.html">BEtapiToken</a></span>
+|
+
+<span class="param-type">null</span>
+
+
+ </dd>
+</dl>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <h4 class="name" id="getEtapiTokens"><span class="type-signature"></span>getEtapiTokens<span class="signature">()</span><span class="type-signature"> &rarr; {Array.&lt;<a href="BEtapiToken.html">BEtapiToken</a>>}</span></h4>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<dl class="details">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <dt class="tag-source">Source:</dt>
+ <dd class="tag-source"><ul class="dummy"><li>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line135">line 135</a>
+ </li></ul></dd>
+
+
+
+
+
+
+
+</dl>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<h5>Returns:</h5>
+
+
+
+
+<dl>
+ <dt>
+ Type
+ </dt>
+ <dd>
+
+<span class="param-type">Array.&lt;<a href="BEtapiToken.html">BEtapiToken</a>></span>
+
+
+ </dd>
+</dl>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <h4 class="name" id="getInstanceName"><span class="type-signature"></span>getInstanceName<span class="signature">()</span><span class="type-signature"> &rarr; {string|null}</span></h4>
+
+
+
+
+
+
+<div class="description">
+ Instance name identifies particular Trilium instance. It can be useful for scripts
+if some action needs to happen on only one specific instance.
+</div>
+
+
+
+
+
+
+
+
+
+
+
+
+
+<dl class="details">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <dt class="tag-source">Source:</dt>
+ <dd class="tag-source"><ul class="dummy"><li>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line87">line 87</a>
+ </li></ul></dd>
+
+
+
+
+
+
+
+</dl>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<h5>Returns:</h5>
+
+
+
+
+<dl>
+ <dt>
+ Type
+ </dt>
+ <dd>
+
+<span class="param-type">string</span>
+|
+
+<span class="param-type">null</span>
+
+
+ </dd>
+</dl>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <h4 class="name" id="getMonthNote"><span class="type-signature"></span>getMonthNote<span class="signature">(date, rootNote<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {<a href="BNote.html">BNote</a>|null}</span></h4>
+
+
+
+
+
+
+<div class="description">
+ Returns month note for given date. If such a note doesn't exist, it is created.
+</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>date</code></td>
+
+
+ <td class="type">
+
+
+<span class="param-type">string</span>
+
+
+
+ </td>
+
+
+ <td class="attributes">
+
+
+
+
+
+ </td>
+
+
+
+
+ <td class="description last">in YYYY-MM format</td>
+ </tr>
+
+
+
+ <tr>
+
+ <td class="name"><code>rootNote</code></td>
+
+
+ <td class="type">
+
+
+<span class="param-type"><a href="BNote.html">BNote</a></span>
+
+
+
+ </td>
+
+
+ <td class="attributes">
+
+ &lt;optional><br>
+
+
+
+
+
+ </td>
+
+
+
+
+ <td class="description last">specify calendar root note, normally leave empty to use the default calendar</td>
+ </tr>
+
+
+ </tbody>
+</table>
+
+
+
+
+
+
+<dl class="details">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <dt class="tag-source">Source:</dt>
+ <dd class="tag-source"><ul class="dummy"><li>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line432">line 432</a>
+ </li></ul></dd>
+
+
+
+
+
+
+
+</dl>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<h5>Returns:</h5>
+
+
+
+
+<dl>
+ <dt>
+ Type
+ </dt>
+ <dd>
+
+<span class="param-type"><a href="BNote.html">BNote</a></span>
+|
+
+<span class="param-type">null</span>
+
+
+ </dd>
+</dl>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <h4 class="name" id="getNote"><span class="type-signature"></span>getNote<span class="signature">(noteId)</span><span class="type-signature"> &rarr; {<a href="BNote.html">BNote</a>|null}</span></h4>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <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>noteId</code></td>
+
+
+ <td class="type">
+
+
+<span class="param-type">string</span>
+
+
+
+ </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="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line94">line 94</a>
+ </li></ul></dd>
+
+
+
+
+
+
+
+</dl>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<h5>Returns:</h5>
+
+
+
+
+<dl>
+ <dt>
+ Type
+ </dt>
+ <dd>
+
+<span class="param-type"><a href="BNote.html">BNote</a></span>
+|
+
+<span class="param-type">null</span>
+
+
+ </dd>
+</dl>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <h4 class="name" id="getNoteWithLabel"><span class="type-signature"></span>getNoteWithLabel<span class="signature">(name, value<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {<a href="BNote.html">BNote</a>|null}</span></h4>
+
+
+
+
+
+
+<div class="description">
+ Retrieves first note with given label name & value
+</div>
+
+
+
+
+
+
+
+
+
+ <h5>Parameters:</h5>
+
+
+<table class="params">
+ <thead>
+ <tr>
+
+ <th>Name</th>
+
+
+ <th>Type</th>
+
+
+ <th>Attributes</th>
+
+
-<span class="param-type"><a href="BNote.html">BNote</a></span>
-|
-<span class="param-type">null</span>
+ <th class="last">Description</th>
+ </tr>
+ </thead>
+ <tbody>
+
- </dd>
-</dl>
+ <tr>
+
+ <td class="name"><code>name</code></td>
+
-
+ <td class="type">
+
+
+<span class="param-type">string</span>
+
+ </td>
+
+ <td class="attributes">
+
+
-
+
+ </td>
-
+
-
- <h4 class="name" id="getInstanceName"><span class="type-signature"></span>getInstanceName<span class="signature">()</span><span class="type-signature"> &rarr; {string|null}</span></h4>
-
+ <td class="description last">attribute name</td>
+ </tr>
+ <tr>
+
+ <td class="name"><code>value</code></td>
+
+ <td class="type">
+
+
+<span class="param-type">string</span>
-<div class="description">
- Instance name identifies particular Trilium instance. It can be useful for scripts
-if some action needs to happen on only one specific instance.
-</div>
+
+ </td>
+
+ <td class="attributes">
+
+ &lt;optional><br>
+
+
+
+ </td>
+
+
+ <td class="description last">attribute value</td>
+ </tr>
+
+ </tbody>
+</table>
@@ -4263,7 +5383,7 @@ if some action needs to happen on only one specific instance.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line86">line 86</a>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line214">line 214</a>
</li></ul></dd>
@@ -4299,7 +5419,7 @@ if some action needs to happen on only one specific instance.
</dt>
<dd>
-<span class="param-type">string</span>
+<span class="param-type"><a href="BNote.html">BNote</a></span>
|
<span class="param-type">null</span>
@@ -4320,7 +5440,7 @@ if some action needs to happen on only one specific instance.
- <h4 class="name" id="getMonthNote"><span class="type-signature"></span>getMonthNote<span class="signature">(date, rootNote<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {<a href="BNote.html">BNote</a>|null}</span></h4>
+ <h4 class="name" id="getNotesWithLabel"><span class="type-signature"></span>getNotesWithLabel<span class="signature">(name, value<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Array.&lt;<a href="BNote.html">BNote</a>>}</span></h4>
@@ -4328,7 +5448,7 @@ if some action needs to happen on only one specific instance.
<div class="description">
- Returns month note for given date. If such note doesn't exist, it is created.
+ Retrieves notes with given label name & value
</div>
@@ -4366,7 +5486,7 @@ if some action needs to happen on only one specific instance.
<tr>
- <td class="name"><code>date</code></td>
+ <td class="name"><code>name</code></td>
<td class="type">
@@ -4390,20 +5510,20 @@ if some action needs to happen on only one specific instance.
- <td class="description last">in YYYY-MM format</td>
+ <td class="description last">attribute name</td>
</tr>
<tr>
- <td class="name"><code>rootNote</code></td>
+ <td class="name"><code>value</code></td>
<td class="type">
-<span class="param-type"><a href="BNote.html">BNote</a></span>
+<span class="param-type">string</span>
@@ -4423,7 +5543,7 @@ if some action needs to happen on only one specific instance.
- <td class="description last">specify calendar root note, normally leave empty to use the default calendar</td>
+ <td class="description last">attribute value</td>
</tr>
@@ -4464,7 +5584,7 @@ if some action needs to happen on only one specific instance.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line384">line 384</a>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line204">line 204</a>
</li></ul></dd>
@@ -4500,10 +5620,7 @@ if some action needs to happen on only one specific instance.
</dt>
<dd>
-<span class="param-type"><a href="BNote.html">BNote</a></span>
-|
-
-<span class="param-type">null</span>
+<span class="param-type">Array.&lt;<a href="BNote.html">BNote</a>></span>
</dd>
@@ -4521,7 +5638,7 @@ if some action needs to happen on only one specific instance.
- <h4 class="name" id="getNote"><span class="type-signature"></span>getNote<span class="signature">(noteId)</span><span class="type-signature"> &rarr; {<a href="BNote.html">BNote</a>|null}</span></h4>
+ <h4 class="name" id="getOption"><span class="type-signature"></span>getOption<span class="signature">(optionName)</span><span class="type-signature"> &rarr; {<a href="BOption.html">BOption</a>|null}</span></h4>
@@ -4561,7 +5678,7 @@ if some action needs to happen on only one specific instance.
<tr>
- <td class="name"><code>noteId</code></td>
+ <td class="name"><code>optionName</code></td>
<td class="type">
@@ -4618,7 +5735,7 @@ if some action needs to happen on only one specific instance.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line93">line 93</a>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line142">line 142</a>
</li></ul></dd>
@@ -4654,7 +5771,7 @@ if some action needs to happen on only one specific instance.
</dt>
<dd>
-<span class="param-type"><a href="BNote.html">BNote</a></span>
+<span class="param-type"><a href="BOption.html">BOption</a></span>
|
<span class="param-type">null</span>
@@ -4675,115 +5792,19 @@ if some action needs to happen on only one specific instance.
- <h4 class="name" id="getNoteWithLabel"><span class="type-signature"></span>getNoteWithLabel<span class="signature">(name, value<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {<a href="BNote.html">BNote</a>|null}</span></h4>
-
-
-
-
-
-
-<div class="description">
- Retrieves first note with given label name & value
-</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>
+ <h4 class="name" id="getOptions"><span class="type-signature"></span>getOptions<span class="signature">()</span><span class="type-signature"> &rarr; {Array.&lt;<a href="BOption.html">BOption</a>>}</span></h4>
- <tr>
-
- <td class="name"><code>name</code></td>
-
-
- <td class="type">
-
-
-<span class="param-type">string</span>
-
-
-
- </td>
-
-
- <td class="attributes">
-
-
-
-
-
- </td>
-
-
-
-
- <td class="description last">attribute name</td>
- </tr>
-
- <tr>
-
- <td class="name"><code>value</code></td>
-
-
- <td class="type">
-
-
-<span class="param-type">string</span>
-
- </td>
-
- <td class="attributes">
-
- &lt;optional><br>
-
-
-
- </td>
-
-
- <td class="description last">attribute value</td>
- </tr>
-
- </tbody>
-</table>
@@ -4819,7 +5840,7 @@ if some action needs to happen on only one specific instance.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line166">line 166</a>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line148">line 148</a>
</li></ul></dd>
@@ -4855,10 +5876,7 @@ if some action needs to happen on only one specific instance.
</dt>
<dd>
-<span class="param-type"><a href="BNote.html">BNote</a></span>
-|
-
-<span class="param-type">null</span>
+<span class="param-type">Array.&lt;<a href="BOption.html">BOption</a>></span>
</dd>
@@ -4876,17 +5894,13 @@ if some action needs to happen on only one specific instance.
- <h4 class="name" id="getNotesWithLabel"><span class="type-signature"></span>getNotesWithLabel<span class="signature">(name, value<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Array.&lt;<a href="BNote.html">BNote</a>>}</span></h4>
+ <h4 class="name" id="getRevision"><span class="type-signature"></span>getRevision<span class="signature">(revisionId)</span><span class="type-signature"> &rarr; {<a href="BRevision.html">BRevision</a>|null}</span></h4>
-<div class="description">
- Retrieves notes with given label name & value
-</div>
-
@@ -4908,8 +5922,6 @@ if some action needs to happen on only one specific instance.
<th>Type</th>
- <th>Attributes</th>
-
@@ -4922,38 +5934,7 @@ if some action needs to happen on only one specific instance.
<tr>
- <td class="name"><code>name</code></td>
-
-
- <td class="type">
-
-
-<span class="param-type">string</span>
-
-
-
- </td>
-
-
- <td class="attributes">
-
-
-
-
-
- </td>
-
-
-
-
- <td class="description last">attribute name</td>
- </tr>
-
-
-
- <tr>
-
- <td class="name"><code>value</code></td>
+ <td class="name"><code>revisionId</code></td>
<td class="type">
@@ -4966,20 +5947,10 @@ if some action needs to happen on only one specific instance.
</td>
- <td class="attributes">
-
- &lt;optional><br>
-
-
-
-
-
- </td>
-
- <td class="description last">attribute value</td>
+ <td class="description last"></td>
</tr>
@@ -5020,7 +5991,7 @@ if some action needs to happen on only one specific instance.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line156">line 156</a>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line122">line 122</a>
</li></ul></dd>
@@ -5056,7 +6027,10 @@ if some action needs to happen on only one specific instance.
</dt>
<dd>
-<span class="param-type">Array.&lt;<a href="BNote.html">BNote</a>></span>
+<span class="param-type"><a href="BRevision.html">BRevision</a></span>
+|
+
+<span class="param-type">null</span>
</dd>
@@ -5126,7 +6100,7 @@ if some action needs to happen on only one specific instance.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line343">line 343</a>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line391">line 391</a>
</li></ul></dd>
@@ -5296,7 +6270,7 @@ if some action needs to happen on only one specific instance.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line362">line 362</a>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line410">line 410</a>
</li></ul></dd>
@@ -5599,7 +6573,7 @@ if some action needs to happen on only one specific instance.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line374">line 374</a>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line422">line 422</a>
</li></ul></dd>
@@ -5664,7 +6638,7 @@ if some action needs to happen on only one specific instance.
<div class="description">
- Returns year note for given year. If such note doesn't exist, it is created.
+ Returns year note for given year. If such a note doesn't exist, it is created.
</div>
@@ -5800,7 +6774,7 @@ if some action needs to happen on only one specific instance.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line394">line 394</a>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line442">line 442</a>
</li></ul></dd>
@@ -5953,7 +6927,7 @@ if some action needs to happen on only one specific instance.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line316">line 316</a>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line364">line 364</a>
</li></ul></dd>
@@ -6108,7 +7082,7 @@ if some action needs to happen on only one specific instance.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line447">line 447</a>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line495">line 495</a>
</li></ul></dd>
@@ -6175,7 +7149,7 @@ if some action needs to happen on only one specific instance.
<div class="description">
Executes given anonymous function on the frontend(s).
-Internally this serializes the anonymous function into string and sends it to frontend(s) via WebSocket.
+Internally, this serializes the anonymous function into string and sends it to frontend(s) via WebSocket.
Note that there can be multiple connected frontend instances (e.g. in different tabs). In such case, all
instances execute the given function.
</div>
@@ -6293,7 +7267,7 @@ instances execute the given function.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line573">line 573</a>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line621">line 621</a>
</li></ul></dd>
@@ -6457,7 +7431,7 @@ you need to make some DB changes, you need to surround your call with api.transa
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line616">line 616</a>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line664">line 664</a>
</li></ul></dd>
@@ -6660,7 +7634,7 @@ you need to make some DB changes, you need to surround your call with api.transa
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line142">line 142</a>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line190">line 190</a>
</li></ul></dd>
@@ -6862,7 +7836,7 @@ you need to make some DB changes, you need to surround your call with api.transa
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line118">line 118</a>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line166">line 166</a>
</li></ul></dd>
@@ -7071,7 +8045,7 @@ This method looks similar to toggleNoteInParent() but differs because we're look
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line428">line 428</a>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line476">line 476</a>
</li></ul></dd>
@@ -7417,7 +8391,7 @@ This method looks similar to toggleNoteInParent() but differs because we're look
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line408">line 408</a>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line456">line 456</a>
</li></ul></dd>
@@ -7641,7 +8615,7 @@ This method looks similar to toggleNoteInParent() but differs because we're look
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line199">line 199</a>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line247">line 247</a>
</li></ul></dd>
@@ -7797,7 +8771,7 @@ exists, then we'll use that transaction.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line438">line 438</a>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line486">line 486</a>
</li></ul></dd>
@@ -7952,7 +8926,7 @@ exists, then we'll use that transaction.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line461">line 461</a>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line509">line 509</a>
</li></ul></dd>
diff --git a/docs/backend_api/global.html b/docs/backend_api/global.html
index b110e0145c..5ce1f70df2 100644
--- a/docs/backend_api/global.html
+++ b/docs/backend_api/global.html
@@ -152,7 +152,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line30">line 30</a>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line31">line 31</a>
</li></ul></dd>
@@ -612,7 +612,7 @@ not for direct use.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line25">line 25</a>
+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line26">line 26</a>
</li></ul></dd>
diff --git a/docs/backend_api/services_backend_script_api.js.html b/docs/backend_api/services_backend_script_api.js.html
index 61e8b1ef09..dedaa6f88d 100644
--- a/docs/backend_api/services_backend_script_api.js.html
+++ b/docs/backend_api/services_backend_script_api.js.html
@@ -48,6 +48,7 @@ const specialNotesService = require("./special_notes");
const branchService = require("./branches");
const exportService = require("./export/zip");
const syncMutex = require("./sync_mutex.js");
+const optionsService = require("./options");
/**
@@ -90,18 +91,18 @@ function BackendScriptApi(currentNote, apiParams) {
/**
* Axios library for HTTP requests. See {@link https://axios-http.com} for documentation
- * @type {axios}
+ * @type {axios}
* @deprecated use native (browser compatible) fetch() instead
*/
this.axios = axios;
/**
- * day.js library for date manipulation. See {@link https://day.js.org} for documentation
+ * day.js library for date manipulation. See {@link https://day.js.org} for documentation
* @type {dayjs}
*/
this.dayjs = dayjs;
- /**
+ /**
* xml2js library for XML parsing. See {@link https://github.com/Leonidas-from-XIV/node-xml2js} for documentation
- * @type {xml2js}
+ * @type {xml2js}
*/
this.xml2js = xml2js;
@@ -134,6 +135,53 @@ function BackendScriptApi(currentNote, apiParams) {
*/
this.getAttribute = attributeId => becca.getAttribute(attributeId);
+ /**
+ * @method
+ * @param {string} attachmentId
+ * @returns {BAttachment|null}
+ */
+ this.getAttachment = attachmentId => becca.getAttachment(attachmentId);
+
+ /**
+ * @method
+ * @param {string} revisionId
+ * @returns {BRevision|null}
+ */
+ this.getRevision = revisionId => becca.getRevision(revisionId);
+
+ /**
+ * @method
+ * @param {string} etapiTokenId
+ * @returns {BEtapiToken|null}
+ */
+ this.getEtapiToken = etapiTokenId => becca.getEtapiToken(etapiTokenId);
+
+ /**
+ * @method
+ * @returns {BEtapiToken[]}
+ */
+ this.getEtapiTokens = () => becca.getEtapiTokens();
+
+ /**
+ * @method
+ * @param {string} optionName
+ * @returns {BOption|null}
+ */
+ this.getOption = optionName => becca.getOption(optionName);
+
+ /**
+ * @method
+ * @returns {BOption[]}
+ */
+ this.getOptions = () => optionsService.getOptions();
+
+ /**
+ * @method
+ * @param {string} attributeId
+ * @returns {BAttribute|null}
+ */
+ this.getAttribute = attributeId => becca.getAttribute(attributeId);
+
/**
* This is a powerful search method - you can search by attributes and their values, e.g.:
* "#dateModified =* MONTH AND #log". See {@link https://github.com/zadam/trilium/wiki/Search} for full documentation for all options
@@ -402,7 +450,7 @@ function BackendScriptApi(currentNote, apiParams) {
this.getWeekNote = dateNoteService.getWeekNote;
/**
- * Returns month note for given date. If such note doesn't exist, it is created.
+ * Returns month note for given date. If such a note doesn't exist, it is created.
*
* @method
* @param {string} date in YYYY-MM format
@@ -412,7 +460,7 @@ function BackendScriptApi(currentNote, apiParams) {
this.getMonthNote = dateNoteService.getMonthNote;
/**
- * Returns year note for given year. If such note doesn't exist, it is created.
+ * Returns year note for given year. If such a note doesn't exist, it is created.
*
* @method
* @param {string} year in YYYY format
@@ -498,7 +546,7 @@ function BackendScriptApi(currentNote, apiParams) {
* @method
* @returns {{syncVersion, appVersion, buildRevision, dbVersion, dataDirectory, buildDate}|*} - object representing basic info about running Trilium version
*/
- this.getAppInfo = () => appInfo
+ this.getAppInfo = () => appInfo;
/**
* Creates a new launcher to the launchbar. If the launcher (id) already exists, it will be updated.
@@ -589,7 +637,7 @@ function BackendScriptApi(currentNote, apiParams) {
/**
* Executes given anonymous function on the frontend(s).
- * Internally this serializes the anonymous function into string and sends it to frontend(s) via WebSocket.
+ * Internally, this serializes the anonymous function into string and sends it to frontend(s) via WebSocket.
* Note that there can be multiple connected frontend instances (e.g. in different tabs). In such case, all
* instances execute the given function.
*
diff --git a/docs/frontend_api/FrontendScriptApi.html b/docs/frontend_api/FrontendScriptApi.html
index bec8e5b9f5..85072e6133 100644
--- a/docs/frontend_api/FrontendScriptApi.html
+++ b/docs/frontend_api/FrontendScriptApi.html
@@ -462,7 +462,7 @@ available in the JS frontend notes. You can use e.g. <code>api.showMessage(api.s
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line372">line 372</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line409">line 409</a>
</li></ul></dd>
@@ -1530,7 +1530,7 @@ See <a href="https://day.js.org">https://day.js.org</a> for documentation
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line380">line 380</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line417">line 417</a>
</li></ul></dd>
@@ -1738,7 +1738,7 @@ See <a href="https://day.js.org">https://day.js.org</a> for documentation
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line546">line 546</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line583">line 583</a>
</li></ul></dd>
@@ -2157,7 +2157,7 @@ See <a href="https://day.js.org">https://day.js.org</a> for documentation
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line369">line 369</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line406">line 406</a>
</li></ul></dd>
@@ -2312,7 +2312,7 @@ See <a href="https://day.js.org">https://day.js.org</a> for documentation
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line283">line 283</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line320">line 320</a>
</li></ul></dd>
@@ -2469,7 +2469,7 @@ See <a href="https://day.js.org">https://day.js.org</a> for documentation
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line590">line 590</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line627">line 627</a>
</li></ul></dd>
@@ -2624,7 +2624,7 @@ See <a href="https://day.js.org">https://day.js.org</a> for documentation
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line582">line 582</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line619">line 619</a>
</li></ul></dd>
@@ -2730,7 +2730,7 @@ See <a href="https://day.js.org">https://day.js.org</a> for documentation
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line392">line 392</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line429">line 429</a>
</li></ul></dd>
@@ -2840,7 +2840,7 @@ See <a href="https://day.js.org">https://day.js.org</a> for documentation
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line426">line 426</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line463">line 463</a>
</li></ul></dd>
@@ -2946,7 +2946,7 @@ See <a href="https://day.js.org">https://day.js.org</a> for documentation
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line386">line 386</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line423">line 423</a>
</li></ul></dd>
@@ -3052,7 +3052,7 @@ See <a href="https://day.js.org">https://day.js.org</a> for documentation
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line441">line 441</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line478">line 478</a>
</li></ul></dd>
@@ -3162,7 +3162,7 @@ See <a href="https://day.js.org">https://day.js.org</a> for documentation
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line418">line 418</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line455">line 455</a>
</li></ul></dd>
@@ -3268,7 +3268,7 @@ See <a href="https://day.js.org">https://day.js.org</a> for documentation
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line398">line 398</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line435">line 435</a>
</li></ul></dd>
@@ -3379,7 +3379,7 @@ implementation of actual widget type.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line435">line 435</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line472">line 472</a>
</li></ul></dd>
@@ -3534,7 +3534,7 @@ implementation of actual widget type.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line450">line 450</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line487">line 487</a>
</li></ul></dd>
@@ -3689,7 +3689,7 @@ implementation of actual widget type.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line494">line 494</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line531">line 531</a>
</li></ul></dd>
@@ -3796,7 +3796,7 @@ if some action needs to happen on only one specific instance.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line276">line 276</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line313">line 313</a>
</li></ul></dd>
@@ -3898,7 +3898,7 @@ if some action needs to happen on only one specific instance.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line410">line 410</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line447">line 447</a>
</li></ul></dd>
@@ -4057,7 +4057,7 @@ if some action needs to happen on only one specific instance.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line512">line 512</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line549">line 549</a>
</li></ul></dd>
@@ -4213,7 +4213,7 @@ if some action needs to happen on only one specific instance.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line246">line 246</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line283">line 283</a>
</li></ul></dd>
@@ -4315,7 +4315,7 @@ if some action needs to happen on only one specific instance.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line404">line 404</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line441">line 441</a>
</li></ul></dd>
@@ -4520,7 +4520,7 @@ otherwise (by e.g. createLink())
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line259">line 259</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line296">line 296</a>
</li></ul></dd>
@@ -4626,7 +4626,7 @@ otherwise (by e.g. createLink())
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line485">line 485</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line522">line 522</a>
</li></ul></dd>
@@ -4781,7 +4781,7 @@ otherwise (by e.g. createLink())
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line503">line 503</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line540">line 540</a>
</li></ul></dd>
@@ -4936,7 +4936,7 @@ otherwise (by e.g. createLink())
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line521">line 521</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line558">line 558</a>
</li></ul></dd>
@@ -5086,7 +5086,7 @@ otherwise (by e.g. createLink())
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line601">line 601</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line638">line 638</a>
</li></ul></dd>
@@ -5593,7 +5593,7 @@ otherwise (by e.g. createLink())
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line290">line 290</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line327">line 327</a>
</li></ul></dd>
@@ -5771,7 +5771,7 @@ otherwise (by e.g. createLink())
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line465">line 465</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line502">line 502</a>
</li></ul></dd>
@@ -5945,7 +5945,7 @@ otherwise (by e.g. createLink())
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line475">line 475</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line512">line 512</a>
</li></ul></dd>
@@ -6100,7 +6100,7 @@ otherwise (by e.g. createLink())
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line575">line 575</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line612">line 612</a>
</li></ul></dd>
@@ -6254,7 +6254,7 @@ otherwise (by e.g. createLink())
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line566">line 566</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line603">line 603</a>
</li></ul></dd>
@@ -6409,7 +6409,7 @@ otherwise (by e.g. createLink())
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line267">line 267</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line304">line 304</a>
</li></ul></dd>
@@ -6445,7 +6445,7 @@ otherwise (by e.g. createLink())
- <h4 class="name" id="runOnBackend"><span class="type-signature"></span>runOnBackend<span class="signature">(script, params)</span><span class="type-signature"> &rarr; {Promise.&lt;any>}</span></h4>
+ <h4 class="name" id="runAsyncOnBackendWithManualTransactionHandling"><span class="type-signature"></span>runAsyncOnBackendWithManualTransactionHandling<span class="signature">(func, params)</span><span class="type-signature"> &rarr; {Promise.&lt;*>}</span></h4>
@@ -6455,6 +6455,11 @@ otherwise (by e.g. createLink())
<div class="description">
Executes given anonymous function on the backend.
Internally this serializes the anonymous function into string and sends it to backend via AJAX.
+This function is meant for advanced needs where an async function is necessary.
+In this case, the automatic request-scoped transaction management is not applied,
+and you need to manually define transaction via api.transactional().
+
+If you have a synchronous function, please use api.runOnBackend().
</div>
@@ -6490,16 +6495,204 @@ Internally this serializes the anonymous function into string and sends it to ba
<tr>
- <td class="name"><code>script</code></td>
+ <td class="name"><code>func</code></td>
<td class="type">
-<span class="param-type">string</span>
+<span class="param-type">function</span>
|
+<span class="param-type">string</span>
+
+
+
+ </td>
+
+
+
+
+
+ <td class="description last">(synchronous) function to be executed on the backend</td>
+ </tr>
+
+
+
+ <tr>
+
+ <td class="name"><code>params</code></td>
+
+
+ <td class="type">
+
+
+<span class="param-type">Array.&lt;?></span>
+
+
+
+ </td>
+
+
+
+
+
+ <td class="description last">list of parameters to the anonymous function to be sent to backend</td>
+ </tr>
+
+
+ </tbody>
+</table>
+
+
+
+
+
+
+<dl class="details">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <dt class="tag-source">Source:</dt>
+ <dd class="tag-source"><ul class="dummy"><li>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line241">line 241</a>
+ </li></ul></dd>
+
+
+
+
+
+
+
+</dl>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<h5>Returns:</h5>
+
+
+<div class="param-desc">
+ return value of the executed function on the backend
+</div>
+
+
+
+<dl>
+ <dt>
+ Type
+ </dt>
+ <dd>
+
+<span class="param-type">Promise.&lt;*></span>
+
+
+ </dd>
+</dl>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <h4 class="name" id="runOnBackend"><span class="type-signature"></span>runOnBackend<span class="signature">(func, params)</span><span class="type-signature"> &rarr; {Promise.&lt;*>}</span></h4>
+
+
+
+
+
+
+<div class="description">
+ Executes given anonymous function on the backend.
+Internally this serializes the anonymous function into string and sends it to backend via AJAX.
+Please make sure that the supplied function is synchronous. Only sync functions will work correctly
+with transaction management. If you really know what you're doing, you can call api.runAsyncOnBackendWithManualTransactionHandling()
+</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>func</code></td>
+
+
+ <td class="type">
+
+
<span class="param-type">function</span>
+|
+
+<span class="param-type">string</span>
@@ -6509,7 +6702,7 @@ Internally this serializes the anonymous function into string and sends it to ba
- <td class="description last">script to be executed on the backend</td>
+ <td class="description last">(synchronous) function to be executed on the backend</td>
</tr>
@@ -6522,7 +6715,7 @@ Internally this serializes the anonymous function into string and sends it to ba
<td class="type">
-<span class="param-type">Array.&lt;any></span>
+<span class="param-type">Array.&lt;?></span>
@@ -6573,7 +6766,7 @@ Internally this serializes the anonymous function into string and sends it to ba
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line189">line 189</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line218">line 218</a>
</li></ul></dd>
@@ -6613,7 +6806,7 @@ Internally this serializes the anonymous function into string and sends it to ba
</dt>
<dd>
-<span class="param-type">Promise.&lt;any></span>
+<span class="param-type">Promise.&lt;*></span>
</dd>
@@ -6733,7 +6926,7 @@ Internally this serializes the anonymous function into string and sends it to ba
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line233">line 233</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line270">line 270</a>
</li></ul></dd>
@@ -6889,7 +7082,7 @@ Internally this serializes the anonymous function into string and sends it to ba
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line221">line 221</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line258">line 258</a>
</li></ul></dd>
@@ -7044,7 +7237,7 @@ Internally this serializes the anonymous function into string and sends it to ba
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line530">line 530</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line567">line 567</a>
</li></ul></dd>
@@ -7195,7 +7388,7 @@ Internally this serializes the anonymous function into string and sends it to ba
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line457">line 457</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line494">line 494</a>
</li></ul></dd>
@@ -7350,7 +7543,7 @@ Internally this serializes the anonymous function into string and sends it to ba
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line324">line 324</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line361">line 361</a>
</li></ul></dd>
@@ -7509,7 +7702,7 @@ Internally this serializes the anonymous function into string and sends it to ba
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line306">line 306</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line343">line 343</a>
</li></ul></dd>
@@ -7646,7 +7839,7 @@ Internally this serializes the anonymous function into string and sends it to ba
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line315">line 315</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line352">line 352</a>
</li></ul></dd>
@@ -7801,7 +7994,7 @@ Internally this serializes the anonymous function into string and sends it to ba
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line298">line 298</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line335">line 335</a>
</li></ul></dd>
@@ -8033,7 +8226,7 @@ Internally this serializes the anonymous function into string and sends it to ba
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line336">line 336</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line373">line 373</a>
</li></ul></dd>
@@ -8215,7 +8408,7 @@ Internally this serializes the anonymous function into string and sends it to ba
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line345">line 345</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line382">line 382</a>
</li></ul></dd>
@@ -8375,7 +8568,7 @@ Internally this serializes the anonymous function into string and sends it to ba
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line354">line 354</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line391">line 391</a>
</li></ul></dd>
@@ -8467,7 +8660,7 @@ Typical use case is when a new note has been created, we should wait until it is
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line558">line 558</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line595">line 595</a>
</li></ul></dd>
diff --git a/docs/frontend_api/services_frontend_script_api.js.html b/docs/frontend_api/services_frontend_script_api.js.html
index 8069c92dd6..eded4a0c0c 100644
--- a/docs/frontend_api/services_frontend_script_api.js.html
+++ b/docs/frontend_api/services_frontend_script_api.js.html
@@ -206,36 +206,73 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
}
/**
- * Executes given anonymous function on the backend.
- * Internally this serializes the anonymous function into string and sends it to backend via AJAX.
- *
- * @method
- * @param {string|Function} script - script to be executed on the backend
- * @param {Array&lt;any>} params - list of parameters to the anonymous function to be sent to backend
- * @returns {Promise&lt;any>} return value of the executed function on the backend
+ * @private
*/
- this.runOnBackend = async (script, params = []) => {
- if (typeof script === "function") {
- script = script.toString();
+ this.__runOnBackendInner = async (func, params, transactional) => {
+ if (typeof func === "function") {
+ func = func.toString();
}
const ret = await server.post('script/exec', {
- script: script,
+ script: func,
params: prepareParams(params),
startNoteId: startNote.noteId,
currentNoteId: currentNote.noteId,
originEntityName: "notes", // currently there's no other entity on the frontend which can trigger event
- originEntityId: originEntity ? originEntity.noteId : null
+ originEntityId: originEntity ? originEntity.noteId : null,
+ transactional
}, "script");
if (ret.success) {
await ws.waitForMaxKnownEntityChangeId();
return ret.executionResult;
- }
- else {
+ } else {
throw new Error(`server error: ${ret.error}`);
}
+ }
+
+ /**
+ * Executes given anonymous function on the backend.
+ * Internally this serializes the anonymous function into string and sends it to backend via AJAX.
+ * Please make sure that the supplied function is synchronous. Only sync functions will work correctly
+ * with transaction management. If you really know what you're doing, you can call api.runAsyncOnBackendWithManualTransactionHandling()
+ *
+ * @method
+ * @param {function|string} func - (synchronous) function to be executed on the backend
+ * @param {Array.&lt;?>} params - list of parameters to the anonymous function to be sent to backend
+ * @returns {Promise&lt;*>} return value of the executed function on the backend
+ */
+ this.runOnBackend = async (func, params = []) => {
+ if (func?.constructor.name === "AsyncFunction" || func?.startsWith?.("async ")) {
+ toastService.showError("You're passing an async function to api.runOnBackend() which will likely not work as you intended. "
+ + "Either make the function synchronous (by removing 'async' keyword), or use api.runAsyncOnBackendWithManualTransactionHandling()");
+ }
+
+ return await this.__runOnBackendInner(func, params, true);
+ };
+
+ /**
+ * Executes given anonymous function on the backend.
+ * Internally this serializes the anonymous function into string and sends it to backend via AJAX.
+ * This function is meant for advanced needs where an async function is necessary.
+ * In this case, the automatic request-scoped transaction management is not applied,
+ * and you need to manually define transaction via api.transactional().
+ *
+ * If you have a synchronous function, please use api.runOnBackend().
+ *
+ * @method
+ * @param {function|string} func - (synchronous) function to be executed on the backend
+ * @param {Array.&lt;?>} params - list of parameters to the anonymous function to be sent to backend
+ * @returns {Promise&lt;*>} return value of the executed function on the backend
+ */
+ this.runAsyncOnBackendWithManualTransactionHandling = async (func, params = []) => {
+ if (func?.constructor.name === "Function" || func?.startsWith?.("function")) {
+ toastService.showError("You're passing a synchronous function to api.runAsyncOnBackendWithManualTransactionHandling(), " +
+ "while you should likely use api.runOnBackend() instead.");
+ }
+
+ return await this.__runOnBackendInner(func, params, false);
};
/**
@@ -528,7 +565,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
* @param {string} date - e.g. "2019-04-29"
* @returns {Promise&lt;FNote>}
*/
- this.getWeekNote = dateNotesService.getWeekNote;
+ this.getWeekNote = dateNotesService.getWeekNote;
/**
* Returns month-note. If it doesn't exist, it is automatically created.
diff --git a/src/services/backend_script_api.js b/src/services/backend_script_api.js
index bbdc2b9347..ba593f4c86 100644
--- a/src/services/backend_script_api.js
+++ b/src/services/backend_script_api.js
@@ -20,6 +20,7 @@ const specialNotesService = require("./special_notes");
const branchService = require("./branches");
const exportService = require("./export/zip");
const syncMutex = require("./sync_mutex.js");
+const optionsService = require("./options");
/**
@@ -62,18 +63,18 @@ function BackendScriptApi(currentNote, apiParams) {
/**
* Axios library for HTTP requests. See {@link https://axios-http.com} for documentation
- * @type {axios}
+ * @type {axios}
* @deprecated use native (browser compatible) fetch() instead
*/
this.axios = axios;
/**
- * day.js library for date manipulation. See {@link https://day.js.org} for documentation
+ * day.js library for date manipulation. See {@link https://day.js.org} for documentation
* @type {dayjs}
*/
this.dayjs = dayjs;
- /**
+ /**
* xml2js library for XML parsing. See {@link https://github.com/Leonidas-from-XIV/node-xml2js} for documentation
- * @type {xml2js}
+ * @type {xml2js}
*/
this.xml2js = xml2js;
@@ -106,6 +107,53 @@ function BackendScriptApi(currentNote, apiParams) {
*/
this.getAttribute = attributeId => becca.getAttribute(attributeId);
+ /**
+ * @method
+ * @param {string} attachmentId
+ * @returns {BAttachment|null}
+ */
+ this.getAttachment = attachmentId => becca.getAttachment(attachmentId);
+
+ /**
+ * @method
+ * @param {string} revisionId
+ * @returns {BRevision|null}
+ */
+ this.getRevision = revisionId => becca.getRevision(revisionId);
+
+ /**
+ * @method
+ * @param {string} etapiTokenId
+ * @returns {BEtapiToken|null}
+ */
+ this.getEtapiToken = etapiTokenId => becca.getEtapiToken(etapiTokenId);
+
+ /**
+ * @method
+ * @returns {BEtapiToken[]}
+ */
+ this.getEtapiTokens = () => becca.getEtapiTokens();
+
+ /**
+ * @method
+ * @param {string} optionName
+ * @returns {BOption|null}
+ */
+ this.getOption = optionName => becca.getOption(optionName);
+
+ /**
+ * @method
+ * @returns {BOption[]}
+ */
+ this.getOptions = () => optionsService.getOptions();
+
+ /**
+ * @method
+ * @param {string} attributeId
+ * @returns {BAttribute|null}
+ */
+ this.getAttribute = attributeId => becca.getAttribute(attributeId);
+
/**
* This is a powerful search method - you can search by attributes and their values, e.g.:
* "#dateModified =* MONTH AND #log". See {@link https://github.com/zadam/trilium/wiki/Search} for full documentation for all options
@@ -374,7 +422,7 @@ function BackendScriptApi(currentNote, apiParams) {
this.getWeekNote = dateNoteService.getWeekNote;
/**
- * Returns month note for given date. If such note doesn't exist, it is created.
+ * Returns month note for given date. If such a note doesn't exist, it is created.
*
* @method
* @param {string} date in YYYY-MM format
@@ -384,7 +432,7 @@ function BackendScriptApi(currentNote, apiParams) {
this.getMonthNote = dateNoteService.getMonthNote;
/**
- * Returns year note for given year. If such note doesn't exist, it is created.
+ * Returns year note for given year. If such a note doesn't exist, it is created.
*
* @method
* @param {string} year in YYYY format
@@ -470,7 +518,7 @@ function BackendScriptApi(currentNote, apiParams) {
* @method
* @returns {{syncVersion, appVersion, buildRevision, dbVersion, dataDirectory, buildDate}|*} - object representing basic info about running Trilium version
*/
- this.getAppInfo = () => appInfo
+ this.getAppInfo = () => appInfo;
/**
* Creates a new launcher to the launchbar. If the launcher (id) already exists, it will be updated.
@@ -561,7 +609,7 @@ function BackendScriptApi(currentNote, apiParams) {
/**
* Executes given anonymous function on the frontend(s).
- * Internally this serializes the anonymous function into string and sends it to frontend(s) via WebSocket.
+ * Internally, this serializes the anonymous function into string and sends it to frontend(s) via WebSocket.
* Note that there can be multiple connected frontend instances (e.g. in different tabs). In such case, all
* instances execute the given function.
*