cdbUpdateDoc: This function updates an existing doc

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/cdbUpdateDoc.R

Description

This essentially means that a revision, corresponding to the '_id' has to be provided. If no '_rev' is given in the cdb list the function gets the doc from the db and takes the rev number for the update

Usage

1

Arguments

cdb

the cdb connection configuration list must contain the cdb$serverName, cdb$port, cdb$DBName and cdb$id. The data which updates the data stored in the doc is provided in cdb$dataList

Details

Updating a doc at couchdb means executing a http "PUT" request. The cdb list must contain the cdb$serverName, cdb$port, cdb$DBName, cdb$id. Since v0.6 the revision of the document should exist at the intended place: cdb$dataList$'_rev'.

getURL() with customrequest = "PUT" does the work. If a needed cdb$ list entry is not provided cdb$error maybe says something about the R side.

Value

cdb

The response of the request is stored in cdb$res after converting the answer by means of fromJSON(). The revision provided by the respons is used for updating the cdb$dataList$'_rev'.

Author(s)

wactbprot

See Also

cdbInit()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## Not run: 
ccc               <- cdbIni()
# I assume a database at localhost:5984 already exists
ccc$DBName        <- "r4couchdb_db"
ccc$dataList      <- list(normalDistRand =  rnorm(20))
ccc               <- cdbAddDoc(ccc)

ccc$dataList$Date <- date()
ccc               <- cdbUpdateDoc(ccc)

## End(Not run)

R4CouchDB documentation built on May 29, 2017, 7:10 p.m.