Get a document from a database.

Description

Get a document from a database.

Usage

1
2
3
doc_get(cushion, dbname, docid, rev = NULL, attachments = FALSE,
  deleted = FALSE, revs = FALSE, revs_info = FALSE, conflicts = FALSE,
  deleted_conflicts = FALSE, local_seq = FALSE, as = "list", ...)

Arguments

cushion

A Cushion object. Required.

dbname

Database name

docid

Document ID

rev

Revision id of the document to get. If NULL, gets current revision

attachments

(logical) Whether to include _attachments field.

deleted

(logical) Whether to include _deleted field.

revs

(logical) Whether to include _revisions field.

revs_info

(logical) Whether to include _revs_info field.

conflicts

(logical) Whether to include _conflicts field.

deleted_conflicts

(logical) Whether to include _deleted_conflicts field.

local_seq

(logical) Whether to include _local_seq field.

as

(character) One of list (default) or json

...

Curl args passed on to one of the HTTP verbs (e.g,. GET, POST, PUT, etc.)

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
20
21
## Not run: 
(x <- Cushion$new())

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

# create a document
doc1 <- '{"name": "drink", "beer": "IPA", "score": 5}'
doc_create(x, dbname="sofadb", doc1, docid="abeer")

doc_get(x, dbname="sofadb", docid="abeer")
revs <- db_revisions(x, dbname="sofadb", docid="abeer")
doc_get(x, dbname="sofadb", docid="abeer", rev=revs[1])
doc_get(x, dbname="sofadb", docid="abeer", rev=revs[2])
doc_get(x, dbname="sofadb", docid="abeer", as='json')
doc_get(x, dbname="sofadb", docid="abeer", revs=TRUE)
doc_get(x, dbname="sofadb", docid="abeer", revs=TRUE, local_seq=TRUE)

## End(Not run)