Closed sckott closed 7 years ago
I'd volunteer to do that!
Is there any new information that should be added, besides updating the code examples to reflect the current status of sofa?
Updated. Please let me know if there's anything else that needs to be added or changed.
hi @katsel - thanks!
I'm changing the pkg a lot, updating it to work with Couchdb v2, and a new way to set the connection. changes are on the branch https://github.com/ropensci/sofa/tree/r6setup I'm nearly done, and will then merge into master - I'll get a tutorial ready too, and ping here , which will have lots of egs. can use in the CouchDB wiki
@katsel I am trying to edit the wiki page, but can't edit it I don't think. I can give some things to add for you to do, or maybe I can get access?
@sckott I'm not an ASF member and I don't have commiter status with CouchDB, so I cannot grant any access rights. I do have edit rights for my own cwiki account though, so if that helps, I could make the changes for you.
that'd be great if you could make changes, thanks! here's what I'd like put in there in place of what's there now:
An easy interface to CouchDB from R. Targeted at CouchDB v2+, but much of the package should work with older versions.
install.packages("sofa")
The below examples assume CouchDB running on http://localhost:5984
library('sofa')
client <- Cushion$new()
<sofa - cushion>
transport: http
host: 127.0.0.1
port: 5984
path:
type:
user:
pwd:
ping(client)
$couchdb
[1] "Welcome"
$version
[1] "2.0.0"
$vendor
$vendor$name
[1] "The Apache Software Foundation"
db_create(client, dbname = 'cats')
$ok
[1] TRUE
db_list(client)
[1] "cats"
doc1 <- '{"name":"leo", "type":"cat", "color": "red"}'
doc_create(client, doc1, dbname = "cats", docid = "doc1")
$ok
[1] TRUE
$id
[1] "doc1"
$rev
[1] "1-a48c98c945bcc05d482bc6f938c89882"
Search for cats that are red
db_query(client, dbname = "cats", selector = list(color = "red"))$docs
[[1]]
[[1]]$`_id`
[1] "e6bb43092edaf8fd987434b8a30cfbdf"
[[1]]$`_rev`
[1] "1-08aef850a23f5ff95869c9cf5d9604dc"
[[1]]$name
[1] "leo"
[[1]]$color
[1] "red"
[[1]]$type
[1] "cat"
Create documents in bulk from a data.frame, list, or JSON as a character string.
db_create(client, dbname = "bulktest")
db_bulk_create(client, dbname = "bulktest", mtcars)
Awesome! I just updated the wiki with the new version. I have taken the liberty of replacing "Search" with "Query the database", as it seems like a more suitable phrasing from my perspective . Thanks for putting all the work into this. I can confirm that the tutorial works as intended (tested with CouchDB 1.6).
Great. Thanks very much @katsel !
https://cwiki.apache.org/confluence/display/COUCHDB/R