Skip to content
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

missing milliseconds in timestamp while querying with mongo.find.all #89

Open
annkochepasova opened this issue Jan 7, 2016 · 4 comments

Comments

@annkochepasova
Copy link

When I switch from working with mongo cursors (mongo.find) to fetching data frames (mongo.find.all) I get a data frame with POSIXct timestamps and those timestamps don't have milliseconds.

E.x:


res = mongo.find.all(...)

tsval = as.numeric(res$timestamp[1])

print(tsval, digits=20) 
# prints 1429294389
cursor = mongo.find(...)

tsval = as.numeric(mongo.bson.value(mongo.cursor.value(cursor), 'timestamp'))

print(tsval, digits=20) 
# prints 1429294389.1229999

Expected behaviour: Should receive the same result with milliseconds in both cases - 1429294389.1229999

@dselivanov
Copy link
Owner

Please, provide fully reproducible example, so I will be able to investigate into this.

@rghermi
Copy link

rghermi commented Jun 20, 2016

Hi,
I'm having the same issue.
When fetching a document from mongoDB using mongo.find.all() the milliseconds of the date are not retrieved.
For ex.
Inser a document into mongoDB:

db.textos.insert({_id: new Date(), fichero : "Cocina para todos.pdf",tipo : "pdf", contenido :"lorem ipsum cocina para todos",meta:"title: cocina facil  : Alberto Chicote", userId : "UserId2", palabras : 55322, status : "new"})

This is the outcome in mongoDB shell:

{ "_id" : ISODate("2016-06-20T10:04:35.389Z"), "fichero" : "Cocina para todos.pdf", "tipo" : "pdf", "contenido" : "lorem ipsum cocina para todos", "meta" : "title: cocina facil : Alberto Chicote", "us
erId" : "UserId2", "palabras" : 55322, "status" : "new" }

The _id is a date format.

From my R script

buf <- mongo.bson.buffer.create()
mongo.bson.buffer.append(buf, "tipo", "pdf")
query <- mongo.bson.from.buffer(buf)
inputTest <- mongo.find.all(mongo,DBNS,query)

inputTest is a list.
This is how the _id is stored in the R list inputTest:

[[2]]$_id
[1] "2016-06-20 12:05:26 CEST"

The milliseconds are missing.

I hope I have provided the evidence to start an investigation.

@rghermi
Copy link

rghermi commented Jun 20, 2016

Hi,
just a note to the comment above,
I'm using rmongodb v 1.8.0

packageVersion("rmongodb")
[1] ‘1.8.0’

@rghermi
Copy link

rghermi commented Jun 26, 2016

Hi,
also specifying the format with 3 milliseconds like:

format(inputTest[[1]]$"_id", "%Y-%m-%d %H:%M:%OS3")

the outcome is:

"2016-06-18 19:11:07.000"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants