Description Usage Arguments Value Examples
List all docs in a given database.
1 2 3 4 5 6 7 8 9 10 11 12 |
cushion |
A |
dbname |
Database name. (character) |
descending |
Return in descending order? (logical) |
startkey |
Document ID to start at. (character) |
endkey |
Document ID to end at. (character) |
limit |
Number document IDs to return. (numeric) |
include_docs |
(logical) If |
as |
(character) One of list (default) or json |
disk |
write to disk or not. By default, data is in the R session; if you give a file path, we'll write data to disk and you'll get back the file path. by default, we save in the R session |
... |
Curl args passed on to |
JSON as a character string or a list (determined by the
as
parameter)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | ## Not run:
user <- Sys.getenv("COUCHDB_TEST_USER")
pwd <- Sys.getenv("COUCHDB_TEST_PWD")
(x <- Cushion$new(user=user, pwd=pwd))
if ("leothelion" %in% db_list(x)) {
invisible(db_delete(x, dbname="leothelion"))
}
db_create(x, dbname='leothelion')
db_bulk_create(x, mtcars, dbname="leothelion")
db_alldocs(x, dbname="leothelion")
db_alldocs(x, dbname="leothelion", as='json')
db_alldocs(x, dbname="leothelion", limit=2)
db_alldocs(x, dbname="leothelion", limit=2, include_docs=TRUE)
# curl options
res <- db_alldocs(x, dbname="leothelion", verbose = TRUE)
# write data to disk - useful when data is very large
## create omdb dataset first
file <- system.file("examples/omdb.json", package = "sofa")
strs <- readLines(file)
if ("omdb" %in% db_list(x)) {
invisible(db_delete(x, dbname="omdb"))
}
db_create(x, dbname='omdb')
invisible(db_bulk_create(x, "omdb", strs))
## get all docs, writing them to disk
res <- db_alldocs(x, dbname="omdb", disk = (f <- tempfile(fileext=".json")))
res
readLines(res, n = 10)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.