-
Notifications
You must be signed in to change notification settings - Fork 65
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
Query help for date stored as string #46
Comments
Can you try this? query <- list(TIMESTAMP = list("$gte" = as.POSIXct("2015-01-01")))
str <- jsonlite::toJSON(query, auto_unbox=TRUE, POSIXt = "mongo")
db.eq_bhav.find(str) |
@jeroenooms I solved this using: start_date <- as.integer(as.Date("2015-01-01"))
query <- paste('{"TIMESTAMP" : {"$gte": ',start_date,' }}', sep='')
d <- con$find(query) But, I'm wondering if there is no way to put nodejs stuff |
Please see the section on selecting by date in the new documentation. Note that a date in R is not the same as a Mongo datetime... |
@jeroen: for clarification, can you confirm that this is working: query <- list(TIMESTAMP = list("$gte" = as.POSIXct("2015-01-01")))
str <- jsonlite::toJSON(query, auto_unbox=TRUE, POSIXt = "mongo") Because str gives: |
@nimame can you open a new issue for this? This might be a bug (but I don't have time to look into it immediately) |
This code works in the MongoDB shell ..
How do I port this to mongolite? I tried the following
qry <- 'db.eq_bhav.find({"TIMESTAMP" : {"$gte": Math.floor(Date.parse("2015-01-01")/8.64e7)}})'
con$find(qry)
I get
Error: Invalid JSON object
I tried adding the quotes but it still doesnt work.
Note: My dates are stored as "days" e.g. as.integer(Sys.Date())
The text was updated successfully, but these errors were encountered: