Closed ColinFay closed 2 years ago
Hey,
Maybe I'm missing something, but is there a way to make doc_create compatible with jsonlite::toJSON()?
doc_create
jsonlite::toJSON()
The example show
doc2 <- '{"name": "samson", "color": "red", "furry": false, "size": 3}' doc_create(x, dbname = "cats", doc2)
But it feels weird to build a JSON object like this.
Though, I have errors when I try to upload JSON object created with {jsonlite} :
{jsonlite}
docker run --rm --name couchdbank -e COUCHDB_USER=bebop -e COUCHDB_PASSWORD=aloula -p 5984:5984 couchdb
library(sofa) x <- Cushion$new( host = "localhost", transport = "http", port = 5984, user = "bebop", pwd = "aloula" ) > x$ping()$couchdb [1] "Welcome" > db_create(x, "bankrcache") $ok [1] TRUE > doc_create(x, "bankrcache", jsonlite::toJSON(iris), docid = "pouet") Error in UseMethod("doc_create_") : no applicable method for 'doc_create_' applied to an object of class "json" > doc_create(x, "bankrcache", jsonlite::toJSON(iris) |> as.character(), docid = "pouet") $error [1] "bad_request" $reason [1] "Document must be a JSON object"
Thanks!
This repository is about to be archived.
Session Info
```r ```Hey,
Maybe I'm missing something, but is there a way to make
doc_create
compatible withjsonlite::toJSON()
?The example show
But it feels weird to build a JSON object like this.
Though, I have errors when I try to upload JSON object created with
{jsonlite}
:Thanks!