if (FALSE) {
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)
}
Run the code above in your browser using DataLab