doc_update: Update a document.

Description Usage Arguments Details Value Examples

View source: R/doc_update.r

Description

Update a document.

Usage

1
doc_update(cushion, dbname, doc, docid, rev, as = "list", ...)

Arguments

cushion

A Cushion object. Required.

dbname

(character) Database name. Required.

doc

(character) Document content. Required.

docid

(character) Document ID. Required.

rev

(character) Revision id. Required.

as

(character) One of list (default) or json

...

Curl args passed on to HttpClient

Details

Internally, this function adds in the docid and revision id, required to do a document update

Value

JSON as a character string or a list (determined by the as parameter)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## Not run: 
user <- Sys.getenv("COUCHDB_TEST_USER")
pwd <- Sys.getenv("COUCHDB_TEST_PWD")
(x <- Cushion$new(user=user, pwd=pwd))

if ("sofadb" %in% db_list(x)) {
  invisible(db_delete(x, dbname="sofadb"))
}
db_create(x, dbname='sofadb')

doc1 <- '{"name":"drink","beer":"IPA"}'
doc_create(x, dbname="sofadb", doc=doc1, docid="b_beer")
doc_get(x, dbname = "sofadb", docid = "b_beer")
revs <- db_revisions(x, dbname = "sofadb", docid = "b_beer")
doc2 <- '{"name":"drink","beer":"IPA","note":"yummy","note2":"yay"}'
doc_update(x, dbname="sofadb", doc=doc2, docid="b_beer", rev=revs[1])
db_revisions(x, dbname = "sofadb", docid = "b_beer")

## End(Not run)

sofa documentation built on July 8, 2020, 6:53 p.m.