< Back

New-CouchDBDocument

Sun Jan 19, 2020 6:32 pm

NAME New-CouchDBDocument



SYNOPSIS

Create a new document.





SYNTAX

New-CouchDBDocument [[-Server] <String>] [[-Port] <Int32>] [-Database] <String> [-Document] <String> [-Data]

<Object> [-BatchMode] [[-Authorization] <String>] [-Ssl] [<CommonParameters>]





DESCRIPTION

Creates a new document in the specified database, using the supplied JSON document structure or [hashtable] object.

If the JSON structure or [hashtable] object includes the _id field, then the document will be created with the

specified document ID.

If the _id field is not specified, a new unique ID will be generated, following whatever UUID algorithm is

configured for that server (Get-Help New-CouchDBUuids).





PARAMETERS

-Server <String>

The CouchDB server name. Default is localhost.



Required? false

Position? 1

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Port <Int32>

The CouchDB server port. Default is 5984.



Required? false

Position? 2

Default value 0

Accept pipeline input? false

Accept wildcard characters? false



-Database <String>

The CouchDB database.



Required? true

Position? 3

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Document <String>

The CouchDB document.



Required? true

Position? 4

Default value

Accept pipeline input? true (ByValue)

Accept wildcard characters? false



-Data <Object>

The data in Json format or hastable.



Required? true

Position? 5

Default value

Accept pipeline input? false

Accept wildcard characters? false



-BatchMode [<SwitchParameter>]

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.



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-Authorization <String>

The CouchDB authorization form; user and password.

Authorization format like this: user:password

ATTENTION: if the password is not specified, it will be prompted.



Required? false

Position? 6

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Ssl [<SwitchParameter>]

Set ssl connection on CouchDB server.

This modify protocol to https and port to 6984.



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



NOTES





CouchDB API:

PUT /{db}/{docid}



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>$data = @{"answer"=42; "ask"="Ultimate Question of Life, the Universe and Everything"}



New-CouchDBDocument -Database test -Document "Hitchhikers"-Data $data -Authorization "admin:password"

The example modify document "Hitchhikers" with data $data; if the element of $data exists, overwrite, else adding

new element.











RELATED LINKS

https://pscouchdb.readthedocs.io/en/lat ... a-document