cdbUpdateDoc {R4CouchDB}R Documentation

This function updates an existing doc

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

cdbUpdateDoc(cdb)

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

## 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)

[Package R4CouchDB version 0.7.5 Index]