@docbrasil/api-systemmanager 1.1.6 → 1.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/user/document.js +15 -2
- package/dist/bundle.cjs +80 -3
- package/dist/bundle.mjs +1 -1
- package/doc/api.md +47 -0
- package/docs/Documents.html +469 -8
- package/docs/user_document.js.html +65 -1
- package/package.json +1 -1
package/doc/api.md
CHANGED
|
@@ -1382,6 +1382,8 @@ Class for documents, permission user
|
|
|
1382
1382
|
|
|
1383
1383
|
* [Documents](#Documents)
|
|
1384
1384
|
* [.add(params, session)](#Documents+add) ⇒ <code>Promise</code>
|
|
1385
|
+
* [.findByIdAndUpdate(id, params, session)](#Documents+findByIdAndUpdate) ⇒ <code>Promise</code>
|
|
1386
|
+
* [.findById(id, session)](#Documents+findById) ⇒ <code>Promise</code>
|
|
1385
1387
|
* [.find(params, session)](#Documents+find) ⇒ <code>Promise</code>
|
|
1386
1388
|
* [.findByIdAndRemove(params, session)](#Documents+findByIdAndRemove) ⇒ <code>Promise.<object></code> \| <code>number</code> \| <code>array.<object></code> \| <code>string</code> \| <code>string</code> \| <code>string</code>
|
|
1387
1389
|
* [.findByIdsAndRemove(params, session)](#Documents+findByIdsAndRemove) ⇒ <code>Promise.<object></code> \| <code>number</code> \| <code>array.<object></code> \| <code>string</code> \| <code>string</code> \| <code>string</code>
|
|
@@ -1449,6 +1451,51 @@ const params = {
|
|
|
1449
1451
|
const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
1450
1452
|
await api.user.document.add(params, session);
|
|
1451
1453
|
```
|
|
1454
|
+
<a name="Documents+findByIdAndUpdate"></a>
|
|
1455
|
+
|
|
1456
|
+
### documents.findByIdAndUpdate(id, params, session) ⇒ <code>Promise</code>
|
|
1457
|
+
Updates a document
|
|
1458
|
+
|
|
1459
|
+
**Kind**: instance method of [<code>Documents</code>](#Documents)
|
|
1460
|
+
**Access**: public
|
|
1461
|
+
**Author**: CloudBrasil <abernardo.br@gmail.com>
|
|
1462
|
+
|
|
1463
|
+
| Param | Type | Description |
|
|
1464
|
+
| --- | --- | --- |
|
|
1465
|
+
| id | <code>string</code> | Document _id |
|
|
1466
|
+
| params | <code>object</code> | Object for document payload to update. It has to be the FULL document data, that you can get with findById |
|
|
1467
|
+
| session | <code>string</code> | Session, token JWT |
|
|
1468
|
+
|
|
1469
|
+
**Example**
|
|
1470
|
+
```js
|
|
1471
|
+
const API = require('@docbrasil/api-systemmanager');
|
|
1472
|
+
const api = new API();
|
|
1473
|
+
const params = { ... };
|
|
1474
|
+
const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
1475
|
+
await api.user.document.findByIdAndUpdate('5edf9f8ee896b817e45b8dad', params, session);
|
|
1476
|
+
```
|
|
1477
|
+
<a name="Documents+findById"></a>
|
|
1478
|
+
|
|
1479
|
+
### documents.findById(id, session) ⇒ <code>Promise</code>
|
|
1480
|
+
Updates a document.
|
|
1481
|
+
IMPORTANT: if your document has a content, it will NOT bring the content.
|
|
1482
|
+
|
|
1483
|
+
**Kind**: instance method of [<code>Documents</code>](#Documents)
|
|
1484
|
+
**Access**: public
|
|
1485
|
+
**Author**: CloudBrasil <abernardo.br@gmail.com>
|
|
1486
|
+
|
|
1487
|
+
| Param | Type | Description |
|
|
1488
|
+
| --- | --- | --- |
|
|
1489
|
+
| id | <code>string</code> | Document _id |
|
|
1490
|
+
| session | <code>string</code> | Session, token JWT |
|
|
1491
|
+
|
|
1492
|
+
**Example**
|
|
1493
|
+
```js
|
|
1494
|
+
const API = require('@docbrasil/api-systemmanager');
|
|
1495
|
+
const api = new API();
|
|
1496
|
+
const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
1497
|
+
await api.user.document.findById('5edf9f8ee896b817e45b8dad', session);
|
|
1498
|
+
```
|
|
1452
1499
|
<a name="Documents+find"></a>
|
|
1453
1500
|
|
|
1454
1501
|
### documents.find(params, session) ⇒ <code>Promise</code>
|
package/docs/Documents.html
CHANGED
|
@@ -1657,7 +1657,7 @@ Checks if a document can be added and it does not repeat its primary key</li>
|
|
|
1657
1657
|
<p class="tag-source">
|
|
1658
1658
|
<a href="user_document.js.html" class="button">View Source</a>
|
|
1659
1659
|
<span>
|
|
1660
|
-
<a href="user_document.js.html">user/document.js</a>, <a href="user_document.js.html#
|
|
1660
|
+
<a href="user_document.js.html">user/document.js</a>, <a href="user_document.js.html#line724">line 724</a>
|
|
1661
1661
|
</span>
|
|
1662
1662
|
</p>
|
|
1663
1663
|
|
|
@@ -2368,7 +2368,7 @@ const retDocs = await api.user.document.checkPrimaryKeys(params, session);</code
|
|
|
2368
2368
|
<p class="tag-source">
|
|
2369
2369
|
<a href="user_document.js.html" class="button">View Source</a>
|
|
2370
2370
|
<span>
|
|
2371
|
-
<a href="user_document.js.html">user/document.js</a>, <a href="user_document.js.html#
|
|
2371
|
+
<a href="user_document.js.html">user/document.js</a>, <a href="user_document.js.html#line327">line 327</a>
|
|
2372
2372
|
</span>
|
|
2373
2373
|
</p>
|
|
2374
2374
|
|
|
@@ -2435,6 +2435,224 @@ await api.user.document.findByIdAndRemove(params, session);</code></pre>
|
|
|
2435
2435
|
|
|
2436
2436
|
|
|
2437
2437
|
|
|
2438
|
+
</div>
|
|
2439
|
+
|
|
2440
|
+
<div class="member">
|
|
2441
|
+
|
|
2442
|
+
|
|
2443
|
+
|
|
2444
|
+
<h4 class="name" id="findById">
|
|
2445
|
+
<a class="href-link" href="#findById">#</a>
|
|
2446
|
+
|
|
2447
|
+
|
|
2448
|
+
<span class='tag'>async</span>
|
|
2449
|
+
|
|
2450
|
+
|
|
2451
|
+
<span class="code-name">
|
|
2452
|
+
|
|
2453
|
+
findById<span class="signature">(id, session)</span><span class="type-signature"> → {Promise}</span>
|
|
2454
|
+
|
|
2455
|
+
</span>
|
|
2456
|
+
</h4>
|
|
2457
|
+
|
|
2458
|
+
|
|
2459
|
+
|
|
2460
|
+
|
|
2461
|
+
<div class="description">
|
|
2462
|
+
Updates a document.
|
|
2463
|
+
IMPORTANT: if your document has a content, it will NOT bring the content.
|
|
2464
|
+
</div>
|
|
2465
|
+
|
|
2466
|
+
|
|
2467
|
+
|
|
2468
|
+
|
|
2469
|
+
|
|
2470
|
+
|
|
2471
|
+
|
|
2472
|
+
|
|
2473
|
+
|
|
2474
|
+
|
|
2475
|
+
<h5>Parameters:</h5>
|
|
2476
|
+
|
|
2477
|
+
<div class="table-container">
|
|
2478
|
+
<table class="params table">
|
|
2479
|
+
<thead>
|
|
2480
|
+
<tr>
|
|
2481
|
+
|
|
2482
|
+
<th>Name</th>
|
|
2483
|
+
|
|
2484
|
+
|
|
2485
|
+
<th>Type</th>
|
|
2486
|
+
|
|
2487
|
+
|
|
2488
|
+
|
|
2489
|
+
|
|
2490
|
+
|
|
2491
|
+
<th class="last">Description</th>
|
|
2492
|
+
</tr>
|
|
2493
|
+
</thead>
|
|
2494
|
+
|
|
2495
|
+
<tbody>
|
|
2496
|
+
|
|
2497
|
+
|
|
2498
|
+
|
|
2499
|
+
<tr class="deep-level-0">
|
|
2500
|
+
|
|
2501
|
+
<td class="name"><code>id</code></td>
|
|
2502
|
+
|
|
2503
|
+
|
|
2504
|
+
<td class="type">
|
|
2505
|
+
|
|
2506
|
+
|
|
2507
|
+
<code class="param-type">string</code>
|
|
2508
|
+
|
|
2509
|
+
|
|
2510
|
+
|
|
2511
|
+
</td>
|
|
2512
|
+
|
|
2513
|
+
|
|
2514
|
+
|
|
2515
|
+
|
|
2516
|
+
|
|
2517
|
+
<td class="description last">Document _id</td>
|
|
2518
|
+
</tr>
|
|
2519
|
+
|
|
2520
|
+
|
|
2521
|
+
|
|
2522
|
+
|
|
2523
|
+
|
|
2524
|
+
<tr class="deep-level-0">
|
|
2525
|
+
|
|
2526
|
+
<td class="name"><code>session</code></td>
|
|
2527
|
+
|
|
2528
|
+
|
|
2529
|
+
<td class="type">
|
|
2530
|
+
|
|
2531
|
+
|
|
2532
|
+
<code class="param-type">string</code>
|
|
2533
|
+
|
|
2534
|
+
|
|
2535
|
+
|
|
2536
|
+
</td>
|
|
2537
|
+
|
|
2538
|
+
|
|
2539
|
+
|
|
2540
|
+
|
|
2541
|
+
|
|
2542
|
+
<td class="description last">Session, token JWT</td>
|
|
2543
|
+
</tr>
|
|
2544
|
+
|
|
2545
|
+
|
|
2546
|
+
|
|
2547
|
+
</tbody>
|
|
2548
|
+
</table>
|
|
2549
|
+
</div>
|
|
2550
|
+
|
|
2551
|
+
|
|
2552
|
+
|
|
2553
|
+
|
|
2554
|
+
|
|
2555
|
+
<dl class="details">
|
|
2556
|
+
|
|
2557
|
+
|
|
2558
|
+
|
|
2559
|
+
|
|
2560
|
+
|
|
2561
|
+
|
|
2562
|
+
|
|
2563
|
+
|
|
2564
|
+
|
|
2565
|
+
|
|
2566
|
+
|
|
2567
|
+
|
|
2568
|
+
|
|
2569
|
+
|
|
2570
|
+
|
|
2571
|
+
|
|
2572
|
+
|
|
2573
|
+
|
|
2574
|
+
<dt class="tag-author">Author:</dt>
|
|
2575
|
+
<dd class="tag-author">
|
|
2576
|
+
<ul>
|
|
2577
|
+
<li><a href="mailto:abernardo.br@gmail.com">CloudBrasil</a></li>
|
|
2578
|
+
</ul>
|
|
2579
|
+
</dd>
|
|
2580
|
+
|
|
2581
|
+
|
|
2582
|
+
|
|
2583
|
+
|
|
2584
|
+
|
|
2585
|
+
|
|
2586
|
+
|
|
2587
|
+
|
|
2588
|
+
|
|
2589
|
+
|
|
2590
|
+
|
|
2591
|
+
|
|
2592
|
+
|
|
2593
|
+
|
|
2594
|
+
<p class="tag-source">
|
|
2595
|
+
<a href="user_document.js.html" class="button">View Source</a>
|
|
2596
|
+
<span>
|
|
2597
|
+
<a href="user_document.js.html">user/document.js</a>, <a href="user_document.js.html#line277">line 277</a>
|
|
2598
|
+
</span>
|
|
2599
|
+
</p>
|
|
2600
|
+
|
|
2601
|
+
</dl>
|
|
2602
|
+
|
|
2603
|
+
|
|
2604
|
+
|
|
2605
|
+
|
|
2606
|
+
|
|
2607
|
+
|
|
2608
|
+
|
|
2609
|
+
|
|
2610
|
+
|
|
2611
|
+
|
|
2612
|
+
|
|
2613
|
+
|
|
2614
|
+
|
|
2615
|
+
|
|
2616
|
+
|
|
2617
|
+
|
|
2618
|
+
|
|
2619
|
+
|
|
2620
|
+
<div class='columns method-parameter'>
|
|
2621
|
+
<div class="column is-2"><label>Returns:</label></div>
|
|
2622
|
+
<div class="column is-10">
|
|
2623
|
+
|
|
2624
|
+
|
|
2625
|
+
|
|
2626
|
+
<div class="columns">
|
|
2627
|
+
|
|
2628
|
+
|
|
2629
|
+
<div class='column is-5 has-text-left'>
|
|
2630
|
+
<label>Type: </label>
|
|
2631
|
+
|
|
2632
|
+
<code class="param-type">Promise</code>
|
|
2633
|
+
|
|
2634
|
+
|
|
2635
|
+
</div>
|
|
2636
|
+
|
|
2637
|
+
</div>
|
|
2638
|
+
|
|
2639
|
+
|
|
2640
|
+
</div>
|
|
2641
|
+
</div>
|
|
2642
|
+
|
|
2643
|
+
|
|
2644
|
+
|
|
2645
|
+
|
|
2646
|
+
<h5>Example</h5>
|
|
2647
|
+
|
|
2648
|
+
|
|
2649
|
+
<pre class="prettyprint"><code>const API = require('@docbrasil/api-systemmanager');
|
|
2650
|
+
const api = new API();
|
|
2651
|
+
const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
2652
|
+
await api.user.document.findById('5edf9f8ee896b817e45b8dad', session);</code></pre>
|
|
2653
|
+
|
|
2654
|
+
|
|
2655
|
+
|
|
2438
2656
|
</div>
|
|
2439
2657
|
|
|
2440
2658
|
<div class="member">
|
|
@@ -2642,7 +2860,7 @@ await api.user.document.findByIdAndRemove(params, session);</code></pre>
|
|
|
2642
2860
|
<p class="tag-source">
|
|
2643
2861
|
<a href="user_document.js.html" class="button">View Source</a>
|
|
2644
2862
|
<span>
|
|
2645
|
-
<a href="user_document.js.html">user/document.js</a>, <a href="user_document.js.html#
|
|
2863
|
+
<a href="user_document.js.html">user/document.js</a>, <a href="user_document.js.html#line411">line 411</a>
|
|
2646
2864
|
</span>
|
|
2647
2865
|
</p>
|
|
2648
2866
|
|
|
@@ -2797,6 +3015,249 @@ await api.user.document.findByIdAndRemove(params, session);</code></pre>
|
|
|
2797
3015
|
|
|
2798
3016
|
|
|
2799
3017
|
|
|
3018
|
+
</div>
|
|
3019
|
+
|
|
3020
|
+
<div class="member">
|
|
3021
|
+
|
|
3022
|
+
|
|
3023
|
+
|
|
3024
|
+
<h4 class="name" id="findByIdAndUpdate">
|
|
3025
|
+
<a class="href-link" href="#findByIdAndUpdate">#</a>
|
|
3026
|
+
|
|
3027
|
+
|
|
3028
|
+
<span class='tag'>async</span>
|
|
3029
|
+
|
|
3030
|
+
|
|
3031
|
+
<span class="code-name">
|
|
3032
|
+
|
|
3033
|
+
findByIdAndUpdate<span class="signature">(id, params, session)</span><span class="type-signature"> → {Promise}</span>
|
|
3034
|
+
|
|
3035
|
+
</span>
|
|
3036
|
+
</h4>
|
|
3037
|
+
|
|
3038
|
+
|
|
3039
|
+
|
|
3040
|
+
|
|
3041
|
+
<div class="description">
|
|
3042
|
+
Updates a document
|
|
3043
|
+
</div>
|
|
3044
|
+
|
|
3045
|
+
|
|
3046
|
+
|
|
3047
|
+
|
|
3048
|
+
|
|
3049
|
+
|
|
3050
|
+
|
|
3051
|
+
|
|
3052
|
+
|
|
3053
|
+
|
|
3054
|
+
<h5>Parameters:</h5>
|
|
3055
|
+
|
|
3056
|
+
<div class="table-container">
|
|
3057
|
+
<table class="params table">
|
|
3058
|
+
<thead>
|
|
3059
|
+
<tr>
|
|
3060
|
+
|
|
3061
|
+
<th>Name</th>
|
|
3062
|
+
|
|
3063
|
+
|
|
3064
|
+
<th>Type</th>
|
|
3065
|
+
|
|
3066
|
+
|
|
3067
|
+
|
|
3068
|
+
|
|
3069
|
+
|
|
3070
|
+
<th class="last">Description</th>
|
|
3071
|
+
</tr>
|
|
3072
|
+
</thead>
|
|
3073
|
+
|
|
3074
|
+
<tbody>
|
|
3075
|
+
|
|
3076
|
+
|
|
3077
|
+
|
|
3078
|
+
<tr class="deep-level-0">
|
|
3079
|
+
|
|
3080
|
+
<td class="name"><code>id</code></td>
|
|
3081
|
+
|
|
3082
|
+
|
|
3083
|
+
<td class="type">
|
|
3084
|
+
|
|
3085
|
+
|
|
3086
|
+
<code class="param-type">string</code>
|
|
3087
|
+
|
|
3088
|
+
|
|
3089
|
+
|
|
3090
|
+
</td>
|
|
3091
|
+
|
|
3092
|
+
|
|
3093
|
+
|
|
3094
|
+
|
|
3095
|
+
|
|
3096
|
+
<td class="description last">Document _id</td>
|
|
3097
|
+
</tr>
|
|
3098
|
+
|
|
3099
|
+
|
|
3100
|
+
|
|
3101
|
+
|
|
3102
|
+
|
|
3103
|
+
<tr class="deep-level-0">
|
|
3104
|
+
|
|
3105
|
+
<td class="name"><code>params</code></td>
|
|
3106
|
+
|
|
3107
|
+
|
|
3108
|
+
<td class="type">
|
|
3109
|
+
|
|
3110
|
+
|
|
3111
|
+
<code class="param-type">object</code>
|
|
3112
|
+
|
|
3113
|
+
|
|
3114
|
+
|
|
3115
|
+
</td>
|
|
3116
|
+
|
|
3117
|
+
|
|
3118
|
+
|
|
3119
|
+
|
|
3120
|
+
|
|
3121
|
+
<td class="description last">Object for document payload to update. It has to be the FULL document data, that you can get with findById</td>
|
|
3122
|
+
</tr>
|
|
3123
|
+
|
|
3124
|
+
|
|
3125
|
+
|
|
3126
|
+
|
|
3127
|
+
|
|
3128
|
+
<tr class="deep-level-0">
|
|
3129
|
+
|
|
3130
|
+
<td class="name"><code>session</code></td>
|
|
3131
|
+
|
|
3132
|
+
|
|
3133
|
+
<td class="type">
|
|
3134
|
+
|
|
3135
|
+
|
|
3136
|
+
<code class="param-type">string</code>
|
|
3137
|
+
|
|
3138
|
+
|
|
3139
|
+
|
|
3140
|
+
</td>
|
|
3141
|
+
|
|
3142
|
+
|
|
3143
|
+
|
|
3144
|
+
|
|
3145
|
+
|
|
3146
|
+
<td class="description last">Session, token JWT</td>
|
|
3147
|
+
</tr>
|
|
3148
|
+
|
|
3149
|
+
|
|
3150
|
+
|
|
3151
|
+
</tbody>
|
|
3152
|
+
</table>
|
|
3153
|
+
</div>
|
|
3154
|
+
|
|
3155
|
+
|
|
3156
|
+
|
|
3157
|
+
|
|
3158
|
+
|
|
3159
|
+
<dl class="details">
|
|
3160
|
+
|
|
3161
|
+
|
|
3162
|
+
|
|
3163
|
+
|
|
3164
|
+
|
|
3165
|
+
|
|
3166
|
+
|
|
3167
|
+
|
|
3168
|
+
|
|
3169
|
+
|
|
3170
|
+
|
|
3171
|
+
|
|
3172
|
+
|
|
3173
|
+
|
|
3174
|
+
|
|
3175
|
+
|
|
3176
|
+
|
|
3177
|
+
|
|
3178
|
+
<dt class="tag-author">Author:</dt>
|
|
3179
|
+
<dd class="tag-author">
|
|
3180
|
+
<ul>
|
|
3181
|
+
<li><a href="mailto:abernardo.br@gmail.com">CloudBrasil</a></li>
|
|
3182
|
+
</ul>
|
|
3183
|
+
</dd>
|
|
3184
|
+
|
|
3185
|
+
|
|
3186
|
+
|
|
3187
|
+
|
|
3188
|
+
|
|
3189
|
+
|
|
3190
|
+
|
|
3191
|
+
|
|
3192
|
+
|
|
3193
|
+
|
|
3194
|
+
|
|
3195
|
+
|
|
3196
|
+
|
|
3197
|
+
|
|
3198
|
+
<p class="tag-source">
|
|
3199
|
+
<a href="user_document.js.html" class="button">View Source</a>
|
|
3200
|
+
<span>
|
|
3201
|
+
<a href="user_document.js.html">user/document.js</a>, <a href="user_document.js.html#line245">line 245</a>
|
|
3202
|
+
</span>
|
|
3203
|
+
</p>
|
|
3204
|
+
|
|
3205
|
+
</dl>
|
|
3206
|
+
|
|
3207
|
+
|
|
3208
|
+
|
|
3209
|
+
|
|
3210
|
+
|
|
3211
|
+
|
|
3212
|
+
|
|
3213
|
+
|
|
3214
|
+
|
|
3215
|
+
|
|
3216
|
+
|
|
3217
|
+
|
|
3218
|
+
|
|
3219
|
+
|
|
3220
|
+
|
|
3221
|
+
|
|
3222
|
+
|
|
3223
|
+
|
|
3224
|
+
<div class='columns method-parameter'>
|
|
3225
|
+
<div class="column is-2"><label>Returns:</label></div>
|
|
3226
|
+
<div class="column is-10">
|
|
3227
|
+
|
|
3228
|
+
|
|
3229
|
+
|
|
3230
|
+
<div class="columns">
|
|
3231
|
+
|
|
3232
|
+
|
|
3233
|
+
<div class='column is-5 has-text-left'>
|
|
3234
|
+
<label>Type: </label>
|
|
3235
|
+
|
|
3236
|
+
<code class="param-type">Promise</code>
|
|
3237
|
+
|
|
3238
|
+
|
|
3239
|
+
</div>
|
|
3240
|
+
|
|
3241
|
+
</div>
|
|
3242
|
+
|
|
3243
|
+
|
|
3244
|
+
</div>
|
|
3245
|
+
</div>
|
|
3246
|
+
|
|
3247
|
+
|
|
3248
|
+
|
|
3249
|
+
|
|
3250
|
+
<h5>Example</h5>
|
|
3251
|
+
|
|
3252
|
+
|
|
3253
|
+
<pre class="prettyprint"><code>const API = require('@docbrasil/api-systemmanager');
|
|
3254
|
+
const api = new API();
|
|
3255
|
+
const params = { ... };
|
|
3256
|
+
const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
3257
|
+
await api.user.document.findByIdAndUpdate('5edf9f8ee896b817e45b8dad', params, session);</code></pre>
|
|
3258
|
+
|
|
3259
|
+
|
|
3260
|
+
|
|
2800
3261
|
</div>
|
|
2801
3262
|
|
|
2802
3263
|
<div class="member">
|
|
@@ -3027,7 +3488,7 @@ await api.user.document.findByIdAndRemove(params, session);</code></pre>
|
|
|
3027
3488
|
<p class="tag-source">
|
|
3028
3489
|
<a href="user_document.js.html" class="button">View Source</a>
|
|
3029
3490
|
<span>
|
|
3030
|
-
<a href="user_document.js.html">user/document.js</a>, <a href="user_document.js.html#
|
|
3491
|
+
<a href="user_document.js.html">user/document.js</a>, <a href="user_document.js.html#line456">line 456</a>
|
|
3031
3492
|
</span>
|
|
3032
3493
|
</p>
|
|
3033
3494
|
|
|
@@ -3389,7 +3850,7 @@ await api.user.document.findByIdsAndRemove(params, session);</code></pre>
|
|
|
3389
3850
|
<p class="tag-source">
|
|
3390
3851
|
<a href="user_document.js.html" class="button">View Source</a>
|
|
3391
3852
|
<span>
|
|
3392
|
-
<a href="user_document.js.html">user/document.js</a>, <a href="user_document.js.html#
|
|
3853
|
+
<a href="user_document.js.html">user/document.js</a>, <a href="user_document.js.html#line772">line 772</a>
|
|
3393
3854
|
</span>
|
|
3394
3855
|
</p>
|
|
3395
3856
|
|
|
@@ -3848,7 +4309,7 @@ const retSearch = await api.user.document.searchDocuments(params, session);</cod
|
|
|
3848
4309
|
<p class="tag-source">
|
|
3849
4310
|
<a href="user_document.js.html" class="button">View Source</a>
|
|
3850
4311
|
<span>
|
|
3851
|
-
<a href="user_document.js.html">user/document.js</a>, <a href="user_document.js.html#
|
|
4312
|
+
<a href="user_document.js.html">user/document.js</a>, <a href="user_document.js.html#line522">line 522</a>
|
|
3852
4313
|
</span>
|
|
3853
4314
|
</p>
|
|
3854
4315
|
|
|
@@ -4364,7 +4825,7 @@ const base64Data = await api.user.document.signedUrl(params, session);</code></p
|
|
|
4364
4825
|
<p class="tag-source">
|
|
4365
4826
|
<a href="user_document.js.html" class="button">View Source</a>
|
|
4366
4827
|
<span>
|
|
4367
|
-
<a href="user_document.js.html">user/document.js</a>, <a href="user_document.js.html#
|
|
4828
|
+
<a href="user_document.js.html">user/document.js</a>, <a href="user_document.js.html#line618">line 618</a>
|
|
4368
4829
|
</span>
|
|
4369
4830
|
</p>
|
|
4370
4831
|
|
|
@@ -4762,7 +5223,7 @@ const base64Data = await api.user.document.signedUrls(params, session);</code></
|
|
|
4762
5223
|
<p class="tag-source">
|
|
4763
5224
|
<a href="user_document.js.html" class="button">View Source</a>
|
|
4764
5225
|
<span>
|
|
4765
|
-
<a href="user_document.js.html">user/document.js</a>, <a href="user_document.js.html#
|
|
5226
|
+
<a href="user_document.js.html">user/document.js</a>, <a href="user_document.js.html#line666">line 666</a>
|
|
4766
5227
|
</span>
|
|
4767
5228
|
</p>
|
|
4768
5229
|
|
|
@@ -312,6 +312,71 @@ class Documents {
|
|
|
312
312
|
}
|
|
313
313
|
}
|
|
314
314
|
|
|
315
|
+
/**
|
|
316
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
317
|
+
* @description Updates a document
|
|
318
|
+
* @param {string} id Document _id
|
|
319
|
+
* @param {object} params Object for document payload to update. It has to be the FULL document data, that you can get with findById
|
|
320
|
+
* @param {string} session Session, token JWT
|
|
321
|
+
* @return {Promise}
|
|
322
|
+
* @public
|
|
323
|
+
* @async
|
|
324
|
+
* @example
|
|
325
|
+
*
|
|
326
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
327
|
+
* const api = new API();
|
|
328
|
+
* const params = { ... };
|
|
329
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
330
|
+
* await api.user.document.findByIdAndUpdate('5edf9f8ee896b817e45b8dad', params, session);
|
|
331
|
+
*/
|
|
332
|
+
async findByIdAndUpdate(id, params, session) {
|
|
333
|
+
const self = this;
|
|
334
|
+
try {
|
|
335
|
+
Joi.assert(params._id, Joi.string().required().error(new Error('_id is required')));
|
|
336
|
+
Joi.assert(params, Joi.object().required().error(new Error('params is required')));
|
|
337
|
+
Joi.assert(session, Joi.string().required().error(new Error('session is required')));
|
|
338
|
+
const {areaId, orgId} = params;
|
|
339
|
+
const apiCall = self._client
|
|
340
|
+
.put(`/organizations/${orgId}/areas/${areaId}/documents/${id}`, params, self._setHeader(session));
|
|
341
|
+
|
|
342
|
+
return self._returnData(await apiCall);
|
|
343
|
+
} catch (ex) {
|
|
344
|
+
throw ex;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
350
|
+
* @description Updates a document.
|
|
351
|
+
* IMPORTANT: if your document has a content, it will NOT bring the content.
|
|
352
|
+
* @param {string} id Document _id
|
|
353
|
+
* @param {string} session Session, token JWT
|
|
354
|
+
* @return {Promise}
|
|
355
|
+
* @public
|
|
356
|
+
* @async
|
|
357
|
+
* @example
|
|
358
|
+
*
|
|
359
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
360
|
+
* const api = new API();
|
|
361
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
362
|
+
* await api.user.document.findById('5edf9f8ee896b817e45b8dad', session);
|
|
363
|
+
*/
|
|
364
|
+
async findById(id, session) {
|
|
365
|
+
const self = this;
|
|
366
|
+
try {
|
|
367
|
+
Joi.assert(params._id, Joi.string().required().error(new Error('_id is required')));
|
|
368
|
+
Joi.assert(params, Joi.object().required().error(new Error('params is required')));
|
|
369
|
+
Joi.assert(session, Joi.string().required().error(new Error('session is required')));
|
|
370
|
+
const {areaId, orgId} = params;
|
|
371
|
+
const apiCall = self._client
|
|
372
|
+
.get(`/organizations/${orgId}/documents/${id}/data/DOC`, params, self._setHeader(session));
|
|
373
|
+
|
|
374
|
+
return self._returnData(await apiCall);
|
|
375
|
+
} catch (ex) {
|
|
376
|
+
throw ex;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
|
|
315
380
|
/**
|
|
316
381
|
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
317
382
|
* @param {object} params Object with params
|
|
@@ -809,7 +874,6 @@ class Documents {
|
|
|
809
874
|
throw ex;
|
|
810
875
|
}
|
|
811
876
|
}
|
|
812
|
-
|
|
813
877
|
}
|
|
814
878
|
|
|
815
879
|
export default Documents;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docbrasil/api-systemmanager",
|
|
3
3
|
"description": "Module API System Manager",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.8",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"htmldoc": "rm -rf docs && jsdoc api/** -d docs -t ./node_modules/better-docs",
|
|
7
7
|
"doc": "rm -rf doc && mkdir doc && jsdoc2md api/**/* api/* > doc/api.md",
|