Closed mjvanhasselt closed 5 years ago
thanks for the report @mjvanhasselt - i'll have a look
@mjvanhasselt reinstall and try again. You'll need to set the digits option like options(digits = 10)
or similar - i added docs about this to ?doc_create
and ?sofa-package
let me know what you think
@sckott Thanks for your help: I compared the one installed through CRAN and the one installed from github (by devtools::install_github("ropensci/sofa")
.
Result: The numbers are not rounded off anymore when using the version obtained from github.
So, thanks very much for this change :)
great, glad it works.
Session Info
```r > sessionInfo() R version 3.5.1 (2018-07-02) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows >= 8 x64 (build 9200) Matrix products: default locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] sofa_0.3.0 loaded via a namespace (and not attached): [1] compiler_3.5.1 R6_2.3.0 tools_3.5.1 httpcode_0.2.0 yaml_2.2.0 curl_3.2 [7] Rcpp_0.12.19 urltools_1.7.1 triebeard_0.3.0 crul_0.6.0 jsonlite_1.5 ```Hi,
I have a cloudant database. In this database there are documents with "_id" fields that were randomly generated at creation. However, I wanted to change the "_id" fields of the documents to give it a time based value, since I need to query the database based on date/time constraints.
I read somewhere that the only way I could change the "_id" values of the documents, would be by creating new documents with the same content, however specifying the "_id" field while creating these new documents. (And subsequently, I could delete the original documents).
The JSON documents in my database are rather large, but to reproduce my issue, I have a small similar JSON document:
{ "_id": "4b752d5686dce33023f75d20e269070f", "_rev": "4-e8fca21cb509c77079b1ff23189ed451", "name": "'s-Graveland", "geoPoint": { "latitude": 52.252765, "longitude": 5.12106 } }
So, I followed the above described approach; for one document this approach looks like this:
all_docs <- db_alldocs(conn, "test")
# find all documents in the databasedoc_with_old_id <- doc_get(conn, dbname = "test", docid = "4b752d5686dce33023f75d20e269070f"
# get a specific documentdoc_with_new_id <- doc_old_id[3:4]
# assign the content (without "_id" to a new objectnew_id <- "123"
# define the new "_id"doc_create(conn, "test", doc_new_id, docid = new_id)
# create a new document with the specific "_id"Where
conn
is a cushion object.As you can see the lattitude in the original JSON object has 6 decimal places and the longitude has 5 decimal places.
When I use
doc_create
to create the new document with the specific "_id" field and I took a look at the contents of this new file, I found out that the original numbers are rounded:{ "_id": "123", "_rev": "1-0624464ffcf2f13d30874a761cca431d", "name": "'s-Graveland", "geoPoint": { "latitude": 52.2528, "longitude": 5.1211 } }
So, the lattitude has now 4 decimal places instead of 6 and the longitude has 4 decimal places instead of the original 5.
Concluding, is it possible to change the "_id" field (or as I did, create a new document and put into it the content of an old document), without rounding any numbers?
Thanks in advance!