doc_update {sofa} | R Documentation |
Update a document.
Description
Update a document.
Usage
doc_update(cushion, dbname, doc, docid, rev, as = "list", ...)
Arguments
cushion |
A |
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 |
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
## 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)
[Package sofa version 0.4.0 Index]