# NOT RUN {
user <- Sys.getenv("COUCHDB_TEST_USER")
pwd <- Sys.getenv("COUCHDB_TEST_PWD")
(x <- Cushion$new(user=user, pwd=pwd))
if ("leoalion" %in% db_list(x)) {
invisible(db_delete(x, dbname="leoalion"))
}
db_create(x, dbname='leoalion')
# no changes
res <- db_changes(x, dbname="leoalion")
res$results
# create a document
doc1 <- '{"name": "drink", "type": "water", "score": 5}'
doc_create(x, dbname="leoalion", doc1, docid="awater")
# now there's changes
res <- db_changes(x, dbname="leoalion")
res$results
# as JSON
db_changes(x, dbname="leoalion", as='json')
# }
Run the code above in your browser using DataLab