Skip to content

Commit

Permalink
Add NoConflict param on Set-CouchDBDocument cmdlet
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoGuadrini committed Jun 4, 2019
1 parent 3625433 commit ff0ac60
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 7 deletions.
11 changes: 10 additions & 1 deletion PSCouchDB/PSCouchDB.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -2631,6 +2631,8 @@ function Set-CouchDBDocument () {
.PARAMETER BatchMode
Write documents to the database at a higher rate by using the batch option.
Documents in the batch may be manually flushed by using the Write-CouchDBFullCommit cmdlet.
.PARAMETER NoConflict
No prevents insertion of a conflicting document.
.PARAMETER Authorization
The CouchDB authorization form; user and password.
Authorization format like this: user:password
Expand Down Expand Up @@ -2661,6 +2663,7 @@ function Set-CouchDBDocument () {
$Data,
[switch] $Replace,
[switch] $BatchMode,
[switch] $NoConflict,
[string] $Authorization,
[switch] $Ssl
)
Expand All @@ -2687,7 +2690,13 @@ function Set-CouchDBDocument () {
}
}
# Check BatchMode
if ($BatchMode.IsPresent) { $Document += "?batch=ok" }
if ($BatchMode.IsPresent) {
$Document += "?batch=ok"
# Check NoConflict
} elseif ($NoConflict.IsPresent -and $Revision) {
$Document += "?rev=$Revision&new_edits=false"
$Revision = $null
}
$Data = $Data | ConvertTo-Json -Depth 99
Send-CouchDBRequest -Server $Server -Port $Port -Method "PUT" -Database $Database -Document $Document -Revision $Revision -Data $Data -Authorization $Authorization -Ssl:$Ssl
}
Expand Down
Binary file modified docs/build/doctrees/cmdlets.doctree
Binary file not shown.
Binary file modified docs/build/doctrees/environment.pickle
Binary file not shown.
4 changes: 2 additions & 2 deletions docs/build/html/_sources/cmdlets.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ Documents
.. code-block:: powershell
Get-CouchDBDocument [[-Server] <String>] [[-Port] <Int32>] [-Database] <String> [[-Document] <String>] [[-Revision] <String>] [-Local] [-Revisions] [-History] [-Attachments] [-AttachmentsInfo] [[-AttachmentsSince] <Array>] [-Conflicts] [-DeletedConflicts] [-Latest] [-LocalSequence] [-Metadata] [[-OpenRevisions] <Array>] [[-Authorization] <String>] [-Ssl] [<CommonParameters>]
**New-CouchDBDocument**

.. code-block:: powershell
Expand All @@ -379,7 +379,7 @@ Documents

.. code-block:: powershell
Set-CouchDBDocument [[-Server] <String>] [[-Port] <Int32>] [-Database] <String> [-Document] <String> [-Revision] <String> [[-Data] <Object>] [-Replace] [-BatchMode] [[-Authorization] <String>] [-Ssl] [<CommonParameters>]
Set-CouchDBDocument [[-Server] <String>] [[-Port] <Int32>] [-Database] <String> [-Document] <String> [-Revision] <String> [[-Data] <Object>] [-Replace] [-BatchMode] [-NoConflict] [[-Authorization] <String>] [-Ssl] [<CommonParameters>]
**Remove-CouchDBDocument**

Expand Down
2 changes: 1 addition & 1 deletion docs/build/html/cmdlets.html
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ <h3>Documents<a class="headerlink" href="#documents" title="Permalink to this he
</pre></div>
</div>
<p><strong>Set-CouchDBDocument</strong></p>
<div class="highlight-powershell notranslate"><div class="highlight"><pre><span></span><span class="nb">Set-CouchDBDocument</span> <span class="p">[[</span><span class="n">-Server</span><span class="p">]</span> <span class="p">&lt;</span><span class="n">String</span><span class="p">&gt;]</span> <span class="p">[[</span><span class="n">-Port</span><span class="p">]</span> <span class="p">&lt;</span><span class="n">Int32</span><span class="p">&gt;]</span> <span class="p">[</span><span class="n">-Database</span><span class="p">]</span> <span class="p">&lt;</span><span class="n">String</span><span class="p">&gt;</span> <span class="p">[</span><span class="n">-Document</span><span class="p">]</span> <span class="p">&lt;</span><span class="n">String</span><span class="p">&gt;</span> <span class="p">[</span><span class="n">-Revision</span><span class="p">]</span> <span class="p">&lt;</span><span class="n">String</span><span class="p">&gt;</span> <span class="p">[[</span><span class="n">-Data</span><span class="p">]</span> <span class="p">&lt;</span><span class="n">Object</span><span class="p">&gt;]</span> <span class="p">[</span><span class="o">-Replace</span><span class="p">]</span> <span class="p">[</span><span class="n">-BatchMode</span><span class="p">]</span> <span class="p">[[</span><span class="n">-Authorization</span><span class="p">]</span> <span class="p">&lt;</span><span class="n">String</span><span class="p">&gt;]</span> <span class="p">[</span><span class="n">-Ssl</span><span class="p">]</span> <span class="p">[&lt;</span><span class="n">CommonParameters</span><span class="p">&gt;]</span>
<div class="highlight-powershell notranslate"><div class="highlight"><pre><span></span><span class="nb">Set-CouchDBDocument</span> <span class="p">[[</span><span class="n">-Server</span><span class="p">]</span> <span class="p">&lt;</span><span class="n">String</span><span class="p">&gt;]</span> <span class="p">[[</span><span class="n">-Port</span><span class="p">]</span> <span class="p">&lt;</span><span class="n">Int32</span><span class="p">&gt;]</span> <span class="p">[</span><span class="n">-Database</span><span class="p">]</span> <span class="p">&lt;</span><span class="n">String</span><span class="p">&gt;</span> <span class="p">[</span><span class="n">-Document</span><span class="p">]</span> <span class="p">&lt;</span><span class="n">String</span><span class="p">&gt;</span> <span class="p">[</span><span class="n">-Revision</span><span class="p">]</span> <span class="p">&lt;</span><span class="n">String</span><span class="p">&gt;</span> <span class="p">[[</span><span class="n">-Data</span><span class="p">]</span> <span class="p">&lt;</span><span class="n">Object</span><span class="p">&gt;]</span> <span class="p">[</span><span class="o">-Replace</span><span class="p">]</span> <span class="p">[</span><span class="n">-BatchMode</span><span class="p">]</span> <span class="p">[</span><span class="n">-NoConflict</span><span class="p">]</span> <span class="p">[[</span><span class="n">-Authorization</span><span class="p">]</span> <span class="p">&lt;</span><span class="n">String</span><span class="p">&gt;]</span> <span class="p">[</span><span class="n">-Ssl</span><span class="p">]</span> <span class="p">[&lt;</span><span class="n">CommonParameters</span><span class="p">&gt;]</span>
</pre></div>
</div>
<p><strong>Remove-CouchDBDocument</strong></p>
Expand Down
Loading

0 comments on commit ff0ac60

Please sign in to comment.