-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
when creating a document in cloudant numbers are rounded #66
Comments
thanks for the report @mjvanhasselt - i'll have a look |
added a %||% fxn in zzz.r change internal fxn check_inputs() to pass getOptions(digits) to digits param in jsonlite::toJSON add docs to pkg level man file and doc_create about how to set digits bump minor version
@mjvanhasselt reinstall and try again. You'll need to set the digits option like 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 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
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!
The text was updated successfully, but these errors were encountered: